01
July
function mythemename_theme_suggestions_page_alter(array &$suggestions, array $variables) { // Get Request Object. $request = \Drupal::request(); // If there is HTTP Exception.. if ($exception = $request->attributes->get('exception')) { // Get the status code. $status_code = $exception->getStatusCode(); if (in_array($status_code, array(401, 403, 404))) { $suggestions[] = 'page__' . $status_code; } } if ($node = \Drupal::routeMatch()->getParameter('node')) { $content_type = $node->bundle(); $suggestions[] = 'page__'.$content_type; } if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical' && $tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term')) { $term = Term::load($tid); $suggestions[] = 'page__taxonomy__' . $term->getVocabularyId(); } }
© 2023.ZedAngle. All Rights Reserved.