Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Generate a simple map with a location pointer.
*
* @param string $location
* Location to use (for example the address).
* @param string $country
* Name of the country to use.
*
* @return string
<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function MODULENAME_wysiwyg_editor_settings_alter(&$settings, $context) {
global $base_url;
if ($context['profile']->editor == 'ckeditor') {
$skins_path = drupal_get_path('module', 'MODULENAME') . '/ckeditor/skins';
// For flexibility we use a variable to get the active skin name.
<?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.
<?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') {
(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')
address:
name : undpaul GmbH
city : Hannover
state : NI
conuntry: Germany
postal : 30449
@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' => ''
);
@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;
/**
* @file
* Custom behaviors for "SHS alter".
*/
(function ($, Drupal) {
/**
* Test some features.
*/
<?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)) {