Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sheanhoxie/6de8dfe3cd076b5a408c697e50413a21 to your computer and use it in GitHub Desktop.

Select an option

Save sheanhoxie/6de8dfe3cd076b5a408c697e50413a21 to your computer and use it in GitHub Desktop.
Drupal 8 - Block suggestions for custom block bundles.
https://www.drupal.org/forum/support/theme-development/2016-05-12/theming-custom-block-types#comment-11184655
/**
* Implements hook_theme_suggestions_HOOK_alter()
* @param array $suggestions
* @param array $variables
*/
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
// Block suggestions for custom block bundles.
if (isset($variables['elements']['content']['#block_content'])) {
array_splice($suggestions, 1, 0, 'block__bundle__' . $variables['elements']['content']['#block_content']->bundle());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment