From 843e6a1483960e756971bf795e6c72eaee8c8ec3 Mon Sep 17 00:00:00 2001 From: ebremner <ebremner@uwaterloo.ca> Date: Tue, 15 Jun 2021 15:36:46 -0400 Subject: [PATCH] ISTWCMS-4704: fixing undefined index errors on contacts --- uw_fdsu_theme_resp.theme | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme index bffaa769..81f5170f 100644 --- a/uw_fdsu_theme_resp.theme +++ b/uw_fdsu_theme_resp.theme @@ -410,6 +410,15 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) { // Get the additional info field. $additional_info = $node->field_uw_ct_contact_info->getValue(); + // If there is additional info, setup render array. + if ($additional_info) { + $additional_info = [ + '#type' => 'processed_text', + '#text' => $additional_info[0]['value'], + '#format' => $additional_info[0]['format'], + ]; + } + // Setup the variables for contact. $variables['contact'] = [ 'title' => $node->getTitle(), @@ -422,17 +431,13 @@ function uw_fdsu_theme_resp_preprocess_node(&$variables) { 'uri' => $profile ? $profile[0]['uri'] : NULL, 'title' => $profile ? $profile[0]['title'] : NULL, ], - 'contact_for' => $node->field_uw_ct_contact_for->value, + 'contact_for' => $node->field_uw_ct_contact_contact_for->value, 'personal_website' => [ 'uri' => $personal_website ? $personal_website[0]['uri'] : NULL, 'title' => $personal_website ? $personal_website[0]['title'] : NULL, ], 'groups' => $uwService->uwGetTermsFromEntityField($node->field_uw_ct_contact_group, 'tags'), - 'additional_info' => [ - '#type' => 'processed_text', - '#text' => $additional_info[0]['value'], - '#format' => $additional_info[0]['format'], - ], + 'additional_info' => $additional_info ? $additional_info : NULL, ]; // Unset the content variable so that we do not -- GitLab