From 35f37767520a448eabdea745707fee76a1158153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Mon, 6 Nov 2023 15:37:10 -0500 Subject: [PATCH] Fix undefined link URL notice (and show non-links!) Ref #242 --- web/themes/custom/agarica/agarica.theme | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/web/themes/custom/agarica/agarica.theme b/web/themes/custom/agarica/agarica.theme index f33ab51..0863b2c 100644 --- a/web/themes/custom/agarica/agarica.theme +++ b/web/themes/custom/agarica/agarica.theme @@ -109,14 +109,22 @@ function agarica_languague_switch_link() { $links_render_array = []; // Transform the links to arrays that can be renderer. foreach ($links as $language => $link) { - $links_render_array[] = [ - '#type' => 'link', - '#url' => $link['url'], - '#title' => $link['title'], - '#options' => [ - 'language' => $link['language'], - ], - ]; + if (isset($link['url'])) { + $links_render_array[] = [ + '#type' => 'link', + '#url' => $link['url'], + '#title' => $link['title'], + '#options' => [ + 'language' => $link['language'], + ], + ]; + } else { + // If there's no URL, we take only the title and don't try to make a link. + $links_render_array[] = [ + '#type' => 'markup', + '#markup' => $link['title'], + ]; + } } return $links_render_array;