Skip to content

Instantly share code, notes, and snippets.

@stborchert
stborchert / visu_config.xsd
Created January 19, 2019 10:46
Part of visu_config.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:group name="AvailablePlugins">
<xsd:choice>
<xsd:element name="openweathermap" type="openweathermap" />
</xsd:choice>
</xsd:group>
<!-- Custom widgets -->
<?php
namespace Drupal\dc_search\Plugin\views\display;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\display\Attachment;
use Drupal\views\ViewExecutable;
/**
* The plugin that handles a single-page attachment display.
<?php
/**
* Implements hook_views_pre_build().
*/
function dingens_search_views_pre_build(ViewExecutable $view) {
$functions = [];
$functions[] = sprintf('dingens_search_views__%s__pre_build', $view->id());
$functions[] = sprintf('dingens_search_views__%s_%s__pre_build', $view->id(), $view->current_display);
foreach ($functions as $callback) {
if (is_callable($callback)) {
/**
* @file
* Custom behaviors for "SHS alter".
*/
(function ($, Drupal) {
/**
* Test some features.
*/
@stborchert
stborchert / custommodule.drush.inc
Created February 18, 2016 13:23
Drupal: Drush command to refresh default config for modules/themes/profiles.
<?php
/**
* @file
* Drush commands.
*/
use Drupal\Core\Config\ConfigInstaller;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
@stborchert
stborchert / gist:9778307
Last active August 29, 2015 13:57
Force Drupal to use English as default language on admin pages.
<?php
/**
* Force Drupal to use English as default language on admin pages and for drush.
*/
if (empty($_REQUEST) || (!empty($_GET['q']) && strpos($_GET['q'], 'admin') !== FALSE)) {
$language_default = array(
'language' => 'en', 'name' => 'English', 'native' => 'English',
'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '',
'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''
);
address:
name : undpaul GmbH
city : Hannover
state : NI
conuntry: Germany
postal : 30449
(function($) {
/**
* Change multi-value dropdown to single-value dropdown and back (visually).
*/
Drupal.behaviors.collapsibleFilterRewriteMultipleSelect = {
attach: function(context, settings) {
$.each(Drupal.settings.collapsibleFilter.multiple_selects, function(name, settings) {
$('select#edit-' + name)
.once('collapsible-filter-multiple-rewrite')
<?php
/**
* Implements hook_views_pre_view().
*/
function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
if (!in_array($view->name, array('NAME_OF_VIEW', 'NAME_OF_VIEWS_DISPLAY'))) {
return;
}
foreach (array('type') as $filter) {
if (!empty($_GET[$filter]) && (is_array($_GET[$filter])) && reset($_GET[$filter]) == 'All') {
<?php
/**
* Implements hook_form_FORM_ID_alter().
*
* Alter views exposed forms for collapsible filters.
*/
function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
if (empty($form_state['view']) || !in_array($form_state['view']->name, array('NAME_OF_VIEW', 'NAME_OF_VIEWS_DISPLAY'))) {
// We alter the exposed form of a single views display, so return if this is
// not the expected view.