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

ISTWCMS-4704: adding template for container and preprocess container function...

ISTWCMS-4704: adding template for container and preprocess container function to add header and footer to layout builder page
parent 6fe93705
No related branches found
No related tags found
1 merge request!34ISTWCMS-4847: adding preprocess to main content area to add classes for 404...
{#
/**
* @file
* Theme override of a container used to wrap child elements.
*
* Used for grouped form items. Can also be used as a theme wrapper for any
* renderable element, to surround it with a <div> and HTML attributes.
* See \Drupal\Core\Render\Element\RenderElement for more
* information on the #theme_wrappers render array property, and
* \Drupal\Core\Render\Element\container for usage of the container render
* element.
*
* Available variables:
* - attributes: HTML attributes for the containing element.
* - children: The rendered child elements of the container.
* - has_parent: A flag to indicate that the container has one or more parent
containers.
*
* @see template_preprocess_container()
*/
#}
{%
set classes = [
has_parent ? 'js-form-wrapper',
has_parent ? 'form-wrapper',
]
%}
{% if header_data %}
<div class="layout uw-contained-width">
{% include '@components/teaser/teaser.twig' with {
'teaser': header_data,
'type': 'header',
} %}
</div>
{% endif %}
<div{{ attributes.addClass(classes) }}>{{ children }}</div>
{% if footer_data %}
<div class="layout uw-contained-width">
{% include '@components/teaser/teaser.twig' with {
'teaser': footer_data,
'type': 'footer',
} %}
</div>
{% endif %}
......@@ -388,3 +388,33 @@ function uw_fdsu_theme_resp_preprocess_block(&$variables) {
}
}
}
/**
* Implements template_preprocess_container().
*/
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'
) {
// 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');
}
}
}
}
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