Last active
February 7, 2019 14:09
-
-
Save calvez/b0d20a8d59b307c938651c8a49724115 to your computer and use it in GitHub Desktop.
drupal theme suggestions
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 hook_theme_suggestions_HOOK() for contact form suggestion. | |
*/ | |
function THEMENAME_theme_suggestions_form_alter(array &$suggestions, array $variables) { | |
$suggestions[] = 'form__' . $variables['element']['#form_id']; | |
} |
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 hook_theme_suggestions_HOOK_alter(). | |
*/ | |
function magnetbank_theme_suggestions_page_alter(array &$suggestions, array $variables) { | |
if ($node = \Drupal::routeMatch()->getParameter('node')) { | |
if(is_numeric($node)) { | |
$node = \Drupal\node\Entity\Node::load($node); | |
} | |
if($node instanceof \Drupal\node\NodeInterface) { | |
array_splice($suggestions, 1, 0, 'page__' . $node->bundle()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment