diff --git a/templates/blocks/block--page-title-block.html.twig b/templates/blocks/block--page-title-block.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..b879f01490312875f9e2e64a49e41e1d7b34169e --- /dev/null +++ b/templates/blocks/block--page-title-block.html.twig @@ -0,0 +1,24 @@ +{% if not featured_image %} + {% + 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 %} + diff --git a/templates/node/node.html.twig b/templates/node/node.html.twig index 59f71c564e6a92488c5191308d96e4d1f16522e4..d4c0666a18959ad610f9400660a5913523ea01d3 100644 --- a/templates/node/node.html.twig +++ b/templates/node/node.html.twig @@ -87,6 +87,14 @@ {{ attach_library('seven/classy.node') }} +{% if view_mode == 'full' %} + {% if node_data.sources %} + {% set featured_image = 'yes' %} + {% else %} + {% set featured_image = 'no' %} + {% endif %} +{% endif %} + {% embed '@layouts/node/node.twig' with { 'classes': classes, 'has_sidebar': sidebar ? 'Yes' : 'No' @@ -96,6 +104,7 @@ <div{{ content_attributes.addClass('node__content') }}> {% include '@components/card/card--node/card--node.twig' with { 'node': node_data, + 'featured_image': featured_image, } %} </div> {% endblock %} diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index ba1de1a50218b55d84d479d02805a8bfddf6353c..801bae98abe95c4c4a035f9869437d7d5d3d118c 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -393,6 +393,49 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) { */ 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 false, we will only + // change if there is a featured image. + $variables['featured_image'] = FALSE; + + // 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'); + + // Set the node type. + $node_type = $node->getType(); + + // Get the list of content types that are allowed to have + // feature images from our service. + $featured_image = $uwService->uwGetFeaturedImageContentTypes(); + + // If node is allowed to have a featured image, make sure that + // node actually has an image. + if (in_array($node_type, array_keys($featured_image))) { + + // Get the field name. + $field_name = $featured_image[$node_type]; + + // Get the image object values from the node. + $image = $node->$field_name->getValue(); + + // If there is an image present, set the variable so that + // the page title will not be displayed. + if ($image) { + $variables['featured_image'] = TRUE; + } + } + } + } + // 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.