From 495225c816308d0298585d80991f0bd5f7a33ca7 Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Mon, 17 May 2021 23:17:43 -0400
Subject: [PATCH] ISTWCMS-4847: adding preprocess to main content area to add
 classes for 404 pages and cleaning up template for main content

---
 templates/regions/region--content.html.twig | 46 ++++++++++-----------
 uw_fdsu_theme_resp.theme                    | 15 +++++++
 2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/templates/regions/region--content.html.twig b/templates/regions/region--content.html.twig
index c72534ed..d9d6a2dd 100644
--- a/templates/regions/region--content.html.twig
+++ b/templates/regions/region--content.html.twig
@@ -1,23 +1,23 @@
-{#
-/**
- * @file
- * Theme override to display a region.
- *
- * Available variables:
- * - content: The content for this region, typically blocks.
- * - attributes: HTML attributes for the region div.
- * - region: The name of the region variable as defined in the theme's
- *   .info.yml file.
- *
- * @see template_preprocess_region()
- */
-#}
-{% embed '@layouts/content/content.twig' with {
-  'classes': classes
-}%}
-
-  {% block content %}
-    {{ content }}
-  {% endblock %}
-
-{% endembed %}
+{#
+/**
+ * @file
+ * Theme override to display a region.
+ *
+ * Available variables:
+ * - content: The content for this region, typically blocks.
+ * - attributes: HTML attributes for the region div.
+ * - region: The name of the region variable as defined in the theme's
+ *   .info.yml file.
+ *
+ * @see template_preprocess_region()
+ */
+#}
+{% embed '@layouts/content/content.twig' with {
+  'classes': classes
+}%}
+
+  {% block content %}
+    {{ content }}
+  {% endblock %}
+
+{% endembed %}
diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme
index 52165720..1a3e6b0e 100644
--- a/uw_fdsu_theme_resp.theme
+++ b/uw_fdsu_theme_resp.theme
@@ -97,6 +97,21 @@ function uw_fdsu_theme_resp_preprocess_region(&$variables) {
       $variables['global_message'] = ['#markup' => trim($global_message)];
     }
   }
+
+  // ISTWCMS-4847.
+  // If we are on the main content section, the check if 404 and add
+  // appropriate classes to display proper width.
+  if ($region == 'content') {
+
+    // Get the route name.
+    $route_name = \Drupal::request()->attributes->get('_route');
+
+    // If we are on 404 page add appropriate classes to show proper width.
+    if ('system.404' === $route_name) {
+      $variables['classes'][] = 'layout';
+      $variables['classes'][] = 'uw-contained-width';
+    }
+  }
 }
 
 /**
-- 
GitLab