-
-
Save neetumorwani/df49159bb3fe137aef53a128f7fbb394 to your computer and use it in GitHub Desktop.
Drupal 8 Paragraphs: Add a theme suggestion based on the paragraph and the type of the current node.
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 | |
/** | |
* Implements theme_suggestions_HOOK_alter(). | |
*/ | |
function mytheme_theme_suggestions_paragraph_alter(array &$suggestions, array $variables) { | |
if ($node = \Drupal::routeMatch()->getParameter('node')) { | |
$paragraph = $variables['elements']['#paragraph']; | |
array_push($suggestions, 'paragraph__' . $paragraph->getType() . '__' . $node->getType()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment