From 4f5f5f369ece6d3c99e88ef9908be2b48f3fc420 Mon Sep 17 00:00:00 2001
From: Eric Bremner <ebremner@uwaterloo.ca>
Date: Mon, 22 Nov 2021 16:00:24 +0000
Subject: [PATCH] ISTWCMS-5129: updating tabs for services

---
 src/Form/ServiceSearchForm.php |  5 -----
 uw_ct_service.module           | 11 ++++++++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/Form/ServiceSearchForm.php b/src/Form/ServiceSearchForm.php
index 11f5d60..ede185b 100644
--- a/src/Form/ServiceSearchForm.php
+++ b/src/Form/ServiceSearchForm.php
@@ -210,11 +210,6 @@ class ServiceSearchForm extends FormBase {
           // in the form submit.
           $form_state->set('tid', $url[3]);
         }
-        else {
-
-          // Throw a Drupal error that there was no service to search.
-          $this->messenger->addError('There is no specific service to be searched.');
-        }
       }
     }
 
diff --git a/uw_ct_service.module b/uw_ct_service.module
index a9cedba..0a56819 100644
--- a/uw_ct_service.module
+++ b/uw_ct_service.module
@@ -143,6 +143,8 @@ function uw_ct_service_preprocess_views_view(&$variables)
   // Putting the service search form into
   // variables so that views template can use it.
   if (in_array($id, $services_ids)) {
+
+    // Put the form into the variables.
     $variables['form_search'] = \Drupal::formBuilder()->getForm('Drupal\uw_ct_service\Form\ServiceSearchForm');
 
     // Get the current path and put into array based on
@@ -150,31 +152,38 @@ function uw_ct_service_preprocess_views_view(&$variables)
     $current_path = \Drupal::service('path.current')->getPath();
     $current_path_parts = explode('/', $current_path);
 
+    // If we have something past /services add the tabs.
     if (isset($current_path_parts[2])) {
+
+      // Tab for Category.
       $content_list[] = [
         'url' => '/taxonomy/term/' . end($current_path_parts),
         'text' => 'Category',
         'active' => strpos($current_path, '/taxonomy/term/') !== false ? 1 : 0,
       ];
 
+      // Tab for A-Z.
       $content_list[] = [
         'url' => '/services/all',
         'text' => 'A-Z',
         'active' => $current_path == '/services/all' ? 1 : 0,
       ];
 
+      // Tab for Audience.
       $content_list[] = [
         'url' => '/services/audience',
         'text' => 'Audience',
         'active' => strpos($current_path, '/services/audience/') !== false ? 1 : 0,
       ];
 
+      // Tab for Popular.
       $content_list[] = [
         'url' => '/services/popular',
-        'text' => 'Audience',
+        'text' => 'Popular',
         'active' => strpos($current_path, '/services/audience/') !== false ? 1 : 0,
       ];
 
+      // Set the tabs in the variables.
       $variables['content_list'] = $content_list;
     }
   }
-- 
GitLab