Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. function my_theme_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  2. // Naming templates based on page title.
  3. if ($node = \Drupal::routeMatch()->getParameter('node')) {
  4. $translation = $node->getTranslation('en');
  5. $suggestions[] = 'page__node__' . strtolower($translation->title->value);
  6. $title = $node->getTitle();
  7. foreach ($suggestions as &$replace) {
  8. $replace = str_replace(' ', '_', $replace);
  9. }
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement