sample files from a smithsonian project
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Block-related functions.
|
||||
*/
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_block().
|
||||
* http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
|
||||
*/
|
||||
function cdesai_emulsify_preprocess_block(&$variables) {
|
||||
if(isset($variables['attributes']['id'])) {
|
||||
$variables['content']['#attributes']['block'] = $variables['attributes']['id'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK_alter().
|
||||
*/
|
||||
function cdesai_emulsify_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
|
||||
// Remove the block and replace dashes with underscores in the block ID to
|
||||
// use for the hook name.
|
||||
if (isset($variables['attributes']['block'])) {
|
||||
$hook = str_replace(array('block-', '-'), array('', '_'), $variables['attributes']['block']);
|
||||
$suggestions[] = $variables['theme_hook_original'] . '__' . $hook;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user