Skip to content
Snippets Groups Projects
Commit b0bbf69e authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-4493: check for sidebar in preprocess node and add class if any section has full width

parent a36cabee
No related branches found
No related tags found
1 merge request!19Feature/istwcms 4208 ebremner unpublishing
......@@ -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)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment