From b0bbf69ea58829c29d17411b13f45b37e7763a43 Mon Sep 17 00:00:00 2001 From: ebremner <ebremner@uwaterloo.ca> Date: Fri, 22 Jan 2021 11:23:33 -0500 Subject: [PATCH] ISTWCMS-4493: check for sidebar in preprocess node and add class if any section has full width --- uw_cfg_common.module | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 1d273c3c..f62c18c1 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -207,6 +207,32 @@ function uw_cfg_common_preprocess_node(&$variables) { // an array to future proof, if there are more pages later. $paths_for_content_moderation = ['latest']; + // ISTWCMS-4493: adding class if section has full width. + // If there is a sidebar on the node, check all sections for full width. + if (isset($variables['sidebar'])) { + + // Get the layouts from the node. + $layouts = $variables['node']->layout_builder__layout->getValue(); + + // Step through each of the layouts and check for full width. + foreach ($layouts as $layout) { + + // Get the layout settings from the section. + $settings = $layout['section']->getLayoutSettings(); + + // If the layout builder style is set to full width, then set + // the classes variable for the node and exit the loop. + if ($settings['layout_builder_styles_style'] == "uw_lbs_full_width") { + + // Add a class to the node for full width on a section. + $variables['attributes']['class'][] = 'uw-section-has-full-width'; + + // Break out of the loop to save computational time. + break; + } + } + } + // Check if we are to add the content moderation place. if (in_array(end($path), $paths_for_content_moderation)) { -- GitLab