Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / simplesamlphp.conf
Created November 28, 2017 15:10
SimpleSAMLphp Nginx Docker4Drupal configuration
location ^~ /simplesaml {
alias /var/www/html/web/simplesaml;
location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
fastcgi_param PATH_INFO $pathinfo if_not_empty;
}
}
@szeidler
szeidler / contenta_jsonapi-json_render_only_full_view_mode.patch
Last active December 28, 2017 09:57
Show JSON API representation of node only on default and full view mode
diff --git a/modules/contenta_enhancements/contenta_enhancements.module b/modules/contenta_enhancements/contenta_enhancements.module
index d1b9951..8f0364b 100644
--- a/modules/contenta_enhancements/contenta_enhancements.module
+++ b/modules/contenta_enhancements/contenta_enhancements.module
@@ -362,7 +362,7 @@ function contenta_enhancements_toolbar_alter(&$items) {
function contenta_enhancements_node_view_alter(array &$build, NodeInterface $entity, EntityViewDisplayInterface $display) {
// Make sure the help pages are left alone.
// TODO: Use the concept of view modes to solve this problem, not this hack.
- if ($entity->bundle() === 'page') {
+ if ($entity->bundle() === 'page' || ($display->getMode() !== 'default' && $display->getMode() !== 'full')) {
@szeidler
szeidler / docker-compose.yml
Created February 11, 2018 10:09
PhantomJS on Docker4Drupal
phantomjs:
image: wernight/phantomjs:2
volumes_from:
- php
links:
- nginx
entrypoint: phantomjs
command: "--ssl-protocol=any --ignore-ssl-errors=true /var/www/html/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768"
@szeidler
szeidler / start-selenium-chrome-node-d4d.sh
Last active February 20, 2018 09:47
Start selenium chrome node with Docker4Drupal
#!/bin/sh
selenium-server -role node -hub http://localhost:4444/grid/register
@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"
@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 / 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 / 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 / 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 / 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