Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* @file
* Default simple view template to display a list of rows.
*
* @ingroup views_templates
*/
?>
<?php if (!empty($title)): ?>
@szeidler
szeidler / local.settings.php
Created September 9, 2015 09:47
Make drupal purge varnish cache after node changes
<?php
// Varnish
$conf['cache_backends'][] = 'sites/all/modules/contrib/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
// Drupal 7 does not cache pages when we invoke hooks during bootstrap. This needs
// to be disabled.
$conf['page_cache_invoke_hooks'] = FALSE;
$conf['reverse_proxy'] = TRUE;
@szeidler
szeidler / drushrc.php
Last active January 8, 2016 09:56
drushrc.php
<?php
// Define module download destination.
$site_path = drush_site_path();
$site_path_parts = explode('/', $site_path);
$clean_site_path_parts = array_slice($site_path_parts, -2, 2);
$clean_site_path = implode('/', $clean_site_path_parts);
if (!empty($clean_site_path)) {
$command_specific['dl']['destination'] = $clean_site_path . '/modules/contrib';
}
@szeidler
szeidler / responsive_video_embed_field.css
Created January 19, 2016 12:59
Responsive video_embed_field – Simple markup as an alternative for https://www.drupal.org/project/fitvids
.embedded-video .player {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embedded-video .player iframe,
.embedded-video .player object,
@szeidler
szeidler / d8-responsive-image-programmatically.php
Created March 15, 2016 08:42
Load and render responsive image from field in Drupal 8
<?php
function _load_header_image($variables) {
if ($node = $variables['node']) {
// Load main_image
$file = $node->field_main_image->entity;
if ($file) {
$variables = array(
'responsive_image_style_id' => 'header_image',
'uri' => $file->getFileUri(),
#!/bin/bash
drush sql-dump --gzip --result-file=backup-xxxx.sql.gz --structure-tables-list=cache,cache_*,cache_filter,cache_form,cache_menu,cache_page,history,sessions,watchdog
@szeidler
szeidler / workaround_missing_vendor_libraries_d8_aegir_migration.sh
Last active April 21, 2016 10:45
Workaround for missing vendor libraries, when migrating D8 sites with aegir
#!/bin/bash
## Aegir has major problems while migrating sites, when the new platform doesn't have the vendor libraries available.
## Here is a workaround for solving that problem.
## Copy the working site into the new platform.
## That needs to be done, to let composer_manager know about all the site package requirements
cp -r /var/aegir/platforms/old_platform/sites/site.name.org /var/aegir/platforms/new_platform/sites/site.name.org.migration
cd /var/aegir/platforms/new_platform
## Initialize composer_manager if not already done
@szeidler
szeidler / inline_entity_form-n1960686-36.patch
Created July 22, 2016 10:48
Add multi_edit support to inline_entity_form
diff --git a/includes/commerce_product.inline_entity_form.inc b/includes/commerce_product.inline_entity_form.inc
index 5dcb6f2..62da0b6 100644
--- a/includes/commerce_product.inline_entity_form.inc
+++ b/includes/commerce_product.inline_entity_form.inc
@@ -160,7 +160,7 @@ class CommerceProductInlineEntityFormController extends EntityInlineEntityFormCo
);
$entity_form['product_details'] = array(
'#type' => 'fieldset',
- '#title' => t('Details'),
+ '#title' => $this->getSetting('multi_edit') ? $product->title . ' (' . $product->sku . ')' : t('Details'),
@szeidler
szeidler / drush-alias-sql-migration.sh
Created October 28, 2016 20:01
Drush Alias SQL migration
drush @live.example.org sql-dump --gzip|zcat|drush sql-cli
@szeidler
szeidler / Gruntfile.js
Last active February 23, 2017 10:23
Grunt files for Drupal theming (including clever drush cache clearing)
/**
* Grunt file for Drupal theming, including clever drush cache clearing.
*
* Usage in docker4drupal environment: `grunt --docker`
* It ensures, that drush is executed from the php container.
*/
module.exports = function (grunt) {
var drush_path = 'drush';