From 6f3cefed926db03c64a9e20c75e17f680afaaa7e Mon Sep 17 00:00:00 2001 From: ebremner <ebremner@uwaterloo.ca> Date: Thu, 17 Jun 2021 09:29:14 -0400 Subject: [PATCH] ISTWCMS-4704: updating a lot of things to use featured image --- templates/container/container.html.twig | 8 +++---- templates/node/node.html.twig | 8 ------- uw_fdsu_theme_resp.theme | 29 +++++-------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/templates/container/container.html.twig b/templates/container/container.html.twig index e0effc3f..f2dd7899 100644 --- a/templates/container/container.html.twig +++ b/templates/container/container.html.twig @@ -27,10 +27,10 @@ %} {% if header_data %} - <div class="layout uw-contained-width"> - {% include '@components/card/card--teaser/card--teaser.twig' with { - 'teaser': header_data, - 'type': 'header', + <div class="node--type-{{ node_type }}"> + {% include '@components/card/card--node/card--node.twig' with { + 'node': header_data, + 'featured_image': featured_image, } %} </div> {% endif %} diff --git a/templates/node/node.html.twig b/templates/node/node.html.twig index d4c0666a..f1a66165 100644 --- a/templates/node/node.html.twig +++ b/templates/node/node.html.twig @@ -87,14 +87,6 @@ {{ 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' diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index 801bae98..97e363de 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -378,6 +378,7 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) { 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 @@ -410,29 +411,7 @@ function uw_fdsu_theme_resp_preprocess_block(&$variables) { // 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; - } - } + $variables['featured_image'] = $uwService->uwCheckNodeForFeaturedImage($node); } } @@ -526,6 +505,10 @@ function uw_fdsu_theme_resp_preprocess_container(&$variables) { // 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'); -- GitLab