Skip to content

Instantly share code, notes, and snippets.

@jenitehan
Last active February 18, 2019 10:24
Show Gist options
  • Save jenitehan/3cce5b6b61ff378ae94c4b3f662d8a82 to your computer and use it in GitHub Desktop.
Save jenitehan/3cce5b6b61ff378ae94c4b3f662d8a82 to your computer and use it in GitHub Desktop.
Alter Drupal 8 block template suggestions by bundle
<?php
function themename_theme_suggestions_block_alter(array &$suggestions, array $variables) {
$elements = $variables['elements'];
if (isset($elements['content']['#block_content'])) {
$bundle = $elements['content']['#block_content']->bundle();
if ($bundle == 'bundle_name') {
$suggestions[] = 'block__template_name';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment