Skip to content

Instantly share code, notes, and snippets.

@laradevitt
Last active September 24, 2017 22:08
Show Gist options
  • Save laradevitt/86644e692492cc04e3d6e693598dc307 to your computer and use it in GitHub Desktop.
Save laradevitt/86644e692492cc04e3d6e693598dc307 to your computer and use it in GitHub Desktop.
(Drupal 8.x) Provide template suggestions for custom block types.
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*
* Original source: @jeff-burnz https://www.drupal.org/node/2724333#comment-11184655
*/
function mytheme_theme_suggestions_block_alter(array &$suggestions, array $vars) {
// Template suggestions for custom block bundles.
if (isset($vars['elements']['content']['#block_content'])) {
array_splice($suggestions, 1, 0, 'block__bundle__' . $vars['elements']['content']['#block_content']->bundle());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment