Fix undefined link URL notice (and show non-links!)

Ref #242
This commit is contained in:
benjamin melançon 2023-11-06 15:37:10 -05:00
parent 94a3767bda
commit 35f3776752

View file

@ -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;