Params and multilanguage

Hi Kirby,

I have this link: http://localhost:8888/triplechallenge/nl/register/event:plog-trail-run-gent
It’s a register page with one GET parameter “event”.
There’s also a language switcher (english and dutch).

If I switch from language NL to EN, get link becomes: http://localhost:8888/triplechallenge/en/register
I lose my GET parameter. Am I doing something wrong?

How can I keep all my params, even when switching the language: http://localhost:8888/triplechallenge/en/register/event:plog-trail-run-gent

You can use urlForLanguage() like this:

    <?php foreach($kirby->languages() as $language): ?>
    <li<?php e($kirby->language() == $language, ' class="active"') ?>>
      <a href="<?= $page->urlForLanguage($language->code(),['params' => ['event' => param('event')]]) ?>" hreflang="<?php echo $language->code() ?>">
        <?= html($language->name()) ?>
    <?php endforeach ?>
1 Like

Brilliant! Thank you :slight_smile: