Last active
February 18, 2019 10:24
-
-
Save jenitehan/3cce5b6b61ff378ae94c4b3f662d8a82 to your computer and use it in GitHub Desktop.
Alter Drupal 8 block template suggestions by bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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