Hi,
I have a multi-language site (En, Ar) and I’m using Switch B from the [docs] (https://getkirby.com/docs/guide/languages/switching-languages) to make my language selector.
Is there a PHP/Kirby way to just show the inactive language? Currently, I’m using a hacky CSS way to hide the active language from the selector.
<nav class="languages">
<ul>
<?php foreach($kirby->languages() as $language): ?>
<?php if ($kirby->language() == $language) continue; ?>
<li>
<a href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>">
<?= html($language->name()) ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
This is what I’m missing. Been trying to do the If statement but always gives an error or still shows both language.
As always, to the rescue. Thank you @texnixe
Hi texnixe,
This post was a while back, and I know there has been a few Kirby releases since, so i’m guessing this code would have changed.
What would be the updated version for this code? @texnixe
Thank you,
The code is still perfectly fine.
You’re right, it still works perfectly. So for those who want to use this for Kirby 4.0.1, I can confirm it works.