Created
July 3, 2017 08:07
-
-
Save frederickjh/bf71d5b1bcd80466b77a83b87a00bc5f to your computer and use it in GitHub Desktop.
This the code is from the "DrupalCon Baltimore 2017: Demystifying Rendered Content in Drupal 8 Twig Files" presentation by Amy Vaillancourt-Sals slide 30 "Create a custom file name suggestion". It adds Twig templates for block bundles.
This file contains hidden or 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
/** | |
* This code is from the "DrupalCon Baltimore 2017: Demystifying Rendered Content in Drupal 8 Twig Files" presentation by Amy Vaillancourt-Sals slide 30 "Create a custom file name suggestion". | |
* Video: https://www.youtube.com/watch?v=qoeRpRkGwmk | |
* Slides: https://drive.google.com/file/d/0B8g8dQw8nc9eV3U4SjZKNWNEWGM/view?usp=sharing | |
* Drupalcon Baltimore Session: https://events.drupal.org/baltimore2017/sessions/demystifying-rendered-content-drupal-8-twig-files | |
* This code adds Twig templates for block bundles. Replace "themename" below with your theme's machine name. | |
* Implements hook_theme_suggestions_HOOK_alter() for templates. | |
* @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__type__' . $variables['elements']['content']['#block_content']->bundle()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment