Skip to content

Instantly share code, notes, and snippets.

@leahtard
Last active July 12, 2018 15:41
Show Gist options
  • Save leahtard/cb3e7860a885fe69ad9f to your computer and use it in GitHub Desktop.
Save leahtard/cb3e7860a885fe69ad9f to your computer and use it in GitHub Desktop.
Create TWIG template suggestions for Drupal 8 custom block types. Enables block--custom-block-type.html.twig
function basic_theme_suggestions_block_alter(array &$suggestions, array $variables) {
$block = $variables['elements'];
$blockType = $block['#configuration']['provider'];
if ($blockType == "block_content") {
$bundle = $block['content']['#block_content']->bundle();
$suggestions[] = 'block__' . $bundle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment