From 9fee5b0b143677c73979087de9552ebbe997add4 Mon Sep 17 00:00:00 2001
From: Eric Bremner <ebremner@uwaterloo.ca>
Date: Wed, 19 Oct 2022 15:23:31 -0400
Subject: [PATCH] ISTWCMS-5880: using media flags instead of logic in PL

---
 templates/blocks/block--page-title-block.html.twig |  9 +--------
 templates/node/node.html.twig                      |  3 ++-
 uw_fdsu_theme_resp.theme                           | 11 ++++++++---
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/templates/blocks/block--page-title-block.html.twig b/templates/blocks/block--page-title-block.html.twig
index f3623409..7c0cbae6 100644
--- a/templates/blocks/block--page-title-block.html.twig
+++ b/templates/blocks/block--page-title-block.html.twig
@@ -1,11 +1,4 @@
-{% set show_title = TRUE %}
-{% if hide_page_title %}
-  {% set show_title = FALSE %}
-{% elseif media == 'yes' %}
-  {% set show_title = FALSE %}
-{% endif %}
-
-{% if show_title  %}
+{% if show_title %}
   {%
     set classes = [
     'block',
diff --git a/templates/node/node.html.twig b/templates/node/node.html.twig
index f59785e0..c90421c0 100644
--- a/templates/node/node.html.twig
+++ b/templates/node/node.html.twig
@@ -100,7 +100,8 @@
     <div{{ content_attributes.addClass('node__content') }}>
       {% include '@components/card/card--node/_card--node.twig' with {
         'node': node_data,
-        'type': 'node'
+        'type': 'node',
+        'media_flags': media_flags
       } %}
     </div>
   {% endblock %}
diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme
index 427367ea..69a85039 100644
--- a/uw_fdsu_theme_resp.theme
+++ b/uw_fdsu_theme_resp.theme
@@ -506,10 +506,15 @@ function uw_fdsu_theme_resp_preprocess_block(&$variables) {
     // Load the node.
     $node = \Drupal::routeMatch()->getParameter('node');
 
+    // If this is a node, check for contact and set if we
+    // have to hide the title.
     if ($node = \Drupal::routeMatch()->getParameter('node')) {
-      if ($node->getType() == 'uw_ct_contact') {
-        $variables['hide_page_title'] = TRUE;
-      }
+
+      // Get the media falgs
+      $media_flags = \Drupal::service('uw_cfg_common.uw_service')->uwGetMediaFlags($node);
+
+      // Set the show title flag.
+      $variables['show_title'] = $media_flags['has_media'] ? FALSE : TRUE;
     }
 
     // ISTWCMS-4943: ensure that we get a node object.
-- 
GitLab