Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / composer-unlimited.sh
Created March 18, 2019 15:35
Runs a composer command without PHP memory limitations
#!/bin/bash
php -d memory_limit=-1 /usr/local/bin/composer
@szeidler
szeidler / ga_node_reports-add_sum_for_graph.patch
Created February 25, 2019 15:48
Add summed up numbers to ga_node_reports graph
diff --git a/ga_node_reports.pages.inc b/ga_node_reports.pages.inc
index f0eb797..8bc4426 100644
--- a/ga_node_reports.pages.inc
+++ b/ga_node_reports.pages.inc
@@ -39,6 +39,13 @@ function ga_node_reports_view_node_report($node) {
// Chart details building.
$chart_date = $chart_page = $chart_session = array();
+ // Sum up pageviews and sessions.
+ $sum = array('pageviews' => 0, 'sessions' => 0);
@szeidler
szeidler / get-human-readable-node-bundle.php
Created December 20, 2018 11:59
Get the human-readable content type of a node object.
<?php
Drupal::config('node.type.' . $node->bundle())->get();
@szeidler
szeidler / mailchimp-increase-template-fetch-limit.patch
Created October 4, 2018 13:13
Increase mailchimp template fetch limit. Otherwise it will only fetch 10 templates per template group
diff --git a/modules/mailchimp_campaign/mailchimp_campaign.module b/modules/mailchimp_campaign/mailchimp_campaign.module
index c781162..2eda7c7 100644
--- a/modules/mailchimp_campaign/mailchimp_campaign.module
+++ b/modules/mailchimp_campaign/mailchimp_campaign.module
@@ -274,7 +274,7 @@ function mailchimp_campaign_list_templates($reset = FALSE) {
if ($chosen) {
$all_templates[$type] = array();
- $response = $mc_templates->getTemplates(array('type' => $type));
+ $response = $mc_templates->getTemplates(array('type' => $type, 'count' => 50));
@szeidler
szeidler / paragraphs_edit-show_contextual_links_even_without_root_parent.patch
Created August 23, 2018 09:12
Show paragraphs edit contextual links, even when no root parent was found. E.g. when using it with entity_embed
@szeidler
szeidler / change_height_ckeditor_text_format.php
Created July 13, 2018 12:46
Change the height of Drupal 8 CKEditor for a specific text format
<?php
/**
* Implements hook_editor_js_settings_alter().
*/
function mymodule_misc_editor_js_settings_alter(array &$settings) {
$settings['editor']['formats'][$my_text_format]['editorSettings']['autoGrow_minHeight'] = '50';
}
@szeidler
szeidler / openx_block_cache.patch
Created June 13, 2018 14:37
Disables the cache for openx blocks
diff --git a/openx.module b/openx.module
index e2932e8..cb696d3 100644
--- a/openx.module
+++ b/openx.module
@@ -19,7 +19,8 @@ function openx_block_info() {
foreach ($zones as $index => $zone) {
if ($zone['id']) {
$blocks[$index] = array(
- 'info' => t('OpenX Zone !id (!name)', array('!id' => $zone['id'], '!name' => (empty($zone['name']) ? t('untitled') : $zone['name']))),
+ 'info' => t('OpenX Zone !id (!name)', array('!id' => $zone['id'], '!name' => (empty($zone['name']) ? t('untitled') : $zone['name']))),
@szeidler
szeidler / ga-opt-out.html
Created June 5, 2018 14:11
Google Analytics Opt-Out Link
<script>
var gaProperty = 'UA-123456789-1';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
@szeidler
szeidler / drupal-nodes-revisioned-unpublished-but-published-in-the-past.sql
Created April 18, 2018 19:17
Show me Drupal nodes, that are revisioned, are unpublished now, but were published sometime in the history
SELECT GROUP_CONCAT(nr.status) as concat, n.* FROM node AS n INNER JOIN node_revision AS nr ON nr.nid = n.nid GROUP BY nr.nid HAVING n.status = 0 AND FIND_IN_SET('1', concat);
@szeidler
szeidler / file_entity-formatter_missing.patch
Created March 9, 2018 06:17
Adds core compatibility for file_entity and Drupal 8.5.0
diff --git a/src/Plugin/Field/FieldFormatter/FileImageFormatter.php b/src/Plugin/Field/FieldFormatter/FileImageFormatter.php
index 8b06009..1f719f2 100644
--- a/src/Plugin/Field/FieldFormatter/FileImageFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/FileImageFormatter.php
@@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* id = "file_image",
* label = @Translation("File Image"),
* field_types = {
- * "uri"
+ * "file_uri"