Home ›
Give custom blocks template suggestions by type and views blocks by view IDGive custom blocks template suggestions by type and views blocks by view ID
Submitted by Benjamin Melançon on July 22, 2016 - 4:52am
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter() for blocks.
*/
function kidneys_theme_suggestions_block_alter(array &$suggestions, array $variables) {
if ($variables['elements']['#base_plugin_id'] == 'block_content') {
$block = $variables['elements']['content']['#block_content'];
$suggestions[] = 'block__' . $block->bundle();
}
if ($variables['elements']['#base_plugin_id'] == 'views_block') {
$suggestions[] = 'block__views_block__' . $variables['elements']['content']['#view_id'];
}
}
?>
Comments
Post new comment