Commit 57c1861c authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents bc36de60 4ad9c49a
{% if featured_image == 'no' %}
{%
set classes = [
'block',
'block-' ~ configuration.provider|clean_class,
'block-' ~ plugin_id|clean_class,
]
%}
<div{{ attributes.addClass(classes) }}>
{% if admin_label %}
<div class="uw-admin-label">{{ admin_label }}</div>
{% endif %}
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{% block content %}
{{ content }}
{% endblock %}
</div>
{% endif %}
{#
/**
* @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="node--type-{{ node_type }}">
{% include '@components/card/card--node/card--node.twig' with {
'node': header_data,
'featured_image': featured_image,
} %}
</div>
{% endif %}
<div{{ attributes.addClass(classes) }}>{{ children }}</div>
{% if footer_data %}
<div class="layout uw-contained-width">
{% include '@components/card/card--teaser/card--teaser.twig' with {
'teaser': footer_data,
'type': 'footer',
} %}
</div>
{% endif %}
{% include '@components/teaser/teaser.twig' with {
{% include '@components/card/card--teaser/card--teaser.twig' with {
'teaser': teaser,
} %}
{% include '@components/contact/contact.twig' with {
'contact': teaser,
}%}
......@@ -93,26 +93,11 @@
} %}
{% block content %}
{{ title_prefix }}
{% if label and not page %}
<h2{{ title_attributes }}>
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h2>
{% endif %}
{{ title_suffix }}
{% if display_submitted %}
<footer class="node__meta">
{{ author_picture }}
<div{{ author_attributes.addClass('node__submitted') }}>
{% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
{{ metadata }}
</div>
</footer>
{% endif %}
<div{{ content_attributes.addClass('node__content') }}>
{{ content }}
{% include '@components/card/card--node/card--node.twig' with {
'node': node_data,
'featured_image': featured_image,
} %}
</div>
{% endblock %}
......
{%
set classes = [
'view',
'view-' ~ id|clean_class,
'view-id-' ~ id,
'view-display-id-' ~ display_id,
dom_id ? 'js-view-dom-id-' ~ dom_id,
]
%}
{% include '@components/view/view--contact/view--contact.twig' with {
'attributes': attributes,
'css_name': css_name,
'css_class': css_class,
'header': header,
'footer': footer,
'rows': rows,
'empty': empty,
'pager': pager,
'exposed': exposed,
'feed_icons': feed_icons,
'more': more,
'title': title,
'title_prefix': title_prefix,
'title_suffix': title_suffix,
'attachment_before': attachment_before,
'attachment_after': attachment_after,
'dom_id': dom_id,
} %}
......@@ -212,6 +212,8 @@ function _uw_fdsu_theme_resp_add_favicons(array &$variables) {
'href' => $favicon_base_path . '/apple-touch-icon.png',
];
$variables['page']['#attached']['html_head_link'][] = [$favicon_apple];
// Manifest needs a full URL.
$favicon_base_path = \Drupal::request()->getSchemeAndHttpHost() . $favicon_base_path;
$manifest = [
'icons' => [
[
......@@ -226,7 +228,7 @@ function _uw_fdsu_theme_resp_add_favicons(array &$variables) {
],
],
];
$manifest = json_encode($manifest);
$manifest = urlencode(json_encode($manifest));
$favicon_manifest = [
'rel' => 'manifest',
'href' => 'data:application/manifest+json,' . $manifest,
......@@ -328,6 +330,63 @@ function _uw_fdsu_theme_resp_get_image_info(FileFieldItemList $field) {
}
}
/**
* Implements hook_preprocess_node().
*
* Set variables for node and teaser.
*/
function uw_fdsu_theme_resp_preprocess_node(&$variables) {
// The types of nodes the need preprocessing.
$nodes_to_preprocess = [
'uw_ct_blog',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_web_page',
'uw_ct_catalog_item',
'uw_ct_contact',
'uw_ct_profile',
];
// Teaser to be preprocessed.
$teasers_to_preprocess = [
'uw_ct_blog',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_web_page',
'uw_ct_catalog_item',
'uw_ct_contact',
'uw_ct_profile',
];
// If there is a node that needs preprocessing,
// set the appropriate variables.
if (in_array($variables['node']->getType(), $nodes_to_preprocess) ||
in_array($variables['node']->getType(), $teasers_to_preprocess)) {
// The UW service object.
$uwService = \Drupal::service('uw_cfg_common.uw_service');
// If on a teaser page get the variables for teaser.
if ($variables['view_mode'] == 'teaser' &&
in_array($variables['node']->getType(), $teasers_to_preprocess)) {
$variables['teaser'] = $uwService->uwGetNodeContent($variables['node'], 'teaser', 'all');
}
// If on a node page get the variables for now.
if ($variables['view_mode'] == 'full' &&
in_array($variables['node']->getType(), $nodes_to_preprocess)) {
$variables['node_data'] = $uwService->uwGetNodeContent($variables['node'], 'full', 'all');
$variables['node_data']['content'] = $variables['content'];
$variables['featured_image'] = $uwService->uwCheckNodeForFeaturedImage($variables['node']);
}
// Unset the content variable, so that we do not get
// a second print of all the content.
unset($variables['content']);
}
}
/**
* Implements hook_preprocess_block().
*
......@@ -335,6 +394,27 @@ function _uw_fdsu_theme_resp_get_image_info(FileFieldItemList $field) {
*/
function uw_fdsu_theme_resp_preprocess_block(&$variables) {
// Look at page title block to see if we have a featured image.
// If we do then, set variable to not show page title.
if ($variables['plugin_id'] == 'page_title_block') {
// Set the featured image variable to no, we will only
// change if there is a featured image.
$variables['featured_image'] = 'no';
// Load the node.
$node = \Drupal::routeMatch()->getParameter('node');
// If there is a node, check that it has a featured image.
if ($node) {
// The UW service object.
$uwService = \Drupal::service('uw_cfg_common.uw_service');
$variables['featured_image'] = $uwService->uwCheckNodeForFeaturedImage($node);
}
}
// If we are in layout builder (this is set much earlier in
// the page load process), then continue to look if we need
// to add the admin_label and css classes.
......@@ -386,3 +466,55 @@ 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') {
// 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',
'uw_ct_contact',
'uw_ct_profile',
];
// Get the node object.
$node = \Drupal::routeMatch()->getParameter('node');
// 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');
// Set variables for featured image.
$variables['node_type'] = str_replace('_', '-', $node->getType());
$variables['featured_image'] = $uwService->uwCheckNodeForFeaturedImage($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');
}
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment