Created
March 28, 2014 19:33
-
-
Save star-szr/9841184 to your computer and use it in GitHub Desktop.
Adding template suggestions for view modes and content types in Drupal 8
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
<?php | |
/** | |
* Implements hook_theme_suggestions_HOOK_alter() for node.html.twig. | |
*/ | |
function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) { | |
// Add template suggestions based on the current view mode. | |
$node = $variables['elements']['#node']; | |
$suggestions[] = 'node__' . $variables['elements']['#view_mode']; | |
$suggestions[] = 'node__' . $node->bundle() . '__' . $variables['elements']['#view_mode']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment