Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / drupal-ajax-accordion.js
Created November 18, 2014 14:40
Use custom jQuery toggle functionality in Drupal 7 to prevent multiple triggered elements, because of updated DOM
(function ($) {
Drupal.behaviors.accordion = {
attach: function (context, settings) {
$('.accordion h3.title').once('accordion', function () {
$('.accordion h3.title').toggle(function () {
// Actions here
}, function () {
// Actions here
});
});
@szeidler
szeidler / loop-fontfiles.scss
Created November 18, 2014 15:01
Generate @font-face for a whole font familiy in several file formats.
/*
* See: http://www.oliverdavies.co.uk/blog/include-css-fonts-using-sass-each-loop
* Usage: font-family: "FuturaBook";
*/
@each $family in FuturaBook, FuturaBold, FuturaBoldItalic, FuturaItalic {
@font-face {
font-family: #{$family};
src: url('../fonts/#{$family}/#{$family}.eot');
src: url('../fonts/#{$family}/#{$family}.eot?#iefix') format('embedded-opentype'),
url('../fonts/#{$family}/#{$family}.woff') format('woff'),
@szeidler
szeidler / drush-up-security-only.sh
Last active August 29, 2015 14:10
Updates all drush core and contrib modules with security issues
drush up --security-only
@szeidler
szeidler / drush-make-keep-working-git.sh
Last active August 29, 2015 14:10
Drush make with keeping the working git directory and concurrency option
drush make --working-copy --concurrency=10 http://makefile.com/makefile.make platform
@szeidler
szeidler / crossbrowser-transparency.scss
Created December 12, 2014 11:54
Add's crossbrowser alpha-transparency background-color ability
// Usage: @include transparent(#000, 0.6);
@mixin transparent($color, $alpha) {
$rgba: rgba($color, $alpha);
$ie-hex-str: ie-hex-str($rgba);
background-color: transparent;
background-color: $rgba;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie-hex-str}, endColorstr=#{$ie-hex-str});
zoom: 1;
}
@szeidler
szeidler / html5-image-with-caption-author.html
Created December 15, 2014 10:20
Clean HTML5 image with caption and author
<figure class="image-captioned">
<img alt="Alternative text" src="http://master.media.ramsalt.dev/sites/master.media.ramsalt.com/files/img_7298.jpg" />
<figcaption>
<span class="image-captioned-text">This is the image caption</span>
<span class="image-captioned-byline">Matts Photoman</span>
</figcaption>
</figure>
@szeidler
szeidler / check-if-cli.php
Created January 27, 2015 16:21
Check if the actual request is coming from PHP CLI
<?php
$sapi = php_sapi_name();
if ($sapi === 'cli') {
print 'This is a cli request';
}
@szeidler
szeidler / unlock-fields.php
Created February 6, 2015 10:09
Unlock drupal fields. For example with devels PHP block
<?php
$field_name = 'field_name';
$field = field_read_field($field_name);
$field['locked'] = 0; // 0: unlock; 1: lock.
field_update_field($field);
@szeidler
szeidler / module_finder.drush
Last active September 1, 2016 21:48
Search in all aliases for module occurrence. Returns hits and version. Usage " ./module_finder.drush module_name"
#!/usr/bin/env drush
<?php
/**
* Usage: " ./module_finder.drush metatag"
* Usage multiple modules: " ./module_finder.drush 'views|metatag"
*/
// Get all aliases.
$aliases = _drush_sitealias_all_list();
@szeidler
szeidler / HotelMigration.inc
Last active October 22, 2016 05:37
Drupal Migration example class of geofield fields.
<?php
class HotelMigration extends Migration {
public function __construct(array $arguments) {
parent::__construct($arguments);
$this->description = t('Import of hotels');
$columns = array(
0 => array('StreetId', 'StreetId'),