From 1b1429e55361730be742247a9dbb48b1ece0a497 Mon Sep 17 00:00:00 2001 From: ebremner <ebremner@uwaterloo.ca> Date: Tue, 8 Jun 2021 22:25:18 -0400 Subject: [PATCH] ISTWCMS-4704: restricting header and footer on layout pages to content types that have headers and footers --- uw_fdsu_theme_resp.theme | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index f8f9b3f5..0c6e727f 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -397,22 +397,39 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) { // Ensure that we are on a layout page. if (\Drupal::routeMatch()->getRouteName() == 'layout_builder.overrides.node.view') { - // The UW service object. - $uwService = \Drupal::service('uw_cfg_common.uw_service'); - // Ensure that we are on the first layout builder container. if ( isset($variables['attributes']['class']) && $variables['attributes']['class'][0] == 'layout-builder' ) { + // The list of content types that will have header + // and footer in layout builder pages. + $content_types = [ + 'uw_ct_blog', + 'uw_ct_news_item', + 'uw_ct_event', + ]; + // Get the node object. $node = \Drupal::routeMatch()->getParameter('node'); - // If there is a node object, get the header and footer data. - if ($node) { - $variables['header_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'header'); - $variables['footer_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'footer'); + // If there is a node object, and it is a content + // type that has header and footer for layout pages, + // get the header and footer. + if ($node && in_array($node->getType(), $content_types)) { + + // The UW service object. + $uwService = \Drupal::service('uw_cfg_common.uw_service'); + + // Get the node object. + $node = \Drupal::routeMatch()->getParameter('node'); + + // If there is a node object, get the header and footer data. + if ($node) { + $variables['header_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'header'); + $variables['footer_data'] = $uwService->uwGetNodeContent($node, 'teaser', 'footer'); + } } } } -- GitLab