Getting Language and Tags in the url together

Hey there.
I got a problem with my language settings and tag filtering. Both is working fine alone but ones I set the language from defalut(“de”) to “en” the tag filter is not working.

I think, i already see the solution: The url is not getting the language code into when is filter for a tag.
i am on the subsite:
I change the language from “de” to “en”:
than i use a tag filter(in this case: “Campain”) that is already translated in the txt files:

So somehow I guess i have to say, if the language is set, use the /en path – But how do i do that?

Here is the code from the menu, where I set the tags and language:

<nav id="menu" class="menu">
  <!-- <?= $item = $site->children()->find('Arbeiten') ?> -->
  <a <?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a> <br/>
  <div class="tagMenu">
    <ul class="tags">
      <?php foreach($tags as $tag): ?>
          <a <?php e(urlencode($tag) == $p, ' class="buttonActive tag"') ?> class="tag" href="<?= url('Arbeiten', ['params' => ['tag' => urlencode($tag)]]) ?>">
            <?= html($tag)?>
      <?php endforeach ?>
  <?php foreach ($site->children()->listed()->offset(1) as $item): ?>
    <a <?php e($item->isOpen(), ' class="active"') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a> <br/>
  <?php endforeach ?>
    <div class="languages">
        <?php foreach($kirby->languages() as $language): ?>
          <span <?php e($kirby->language() == $language, ' class="buttonActive langActive"') ?>>
          <a class="tag" href="<?= $page->url($language->code()) ?>">
            <?= html($language->name()) ?>
      <?php endforeach ?>

Hm, the URL should actually automatically add the correct language URL, but you can use a language parameter on the options array

'params' => ['tag' => urlencode($tag)],
'language' => $kirby->language()->code()

(not tested)

@texnixe Unfortunately it’s not working with this added parameter.

Hm, I can’t reproduce this, for me this code

echo url('photography', ['params' => ['tag' => 'blue']]);

in a multi-language Starterkit always returns the language specific url…:thinking:

Mh. I build the site from the Starterkit and proceded for both, mulitlanguage and tag filtering as required.
You think of some partes of the code that could help you understand what is going on?
I put some varibels in the site.php controller… got no more ideas, what went wrong. :grimacing:

If you like, you can send me a zipped version of the project as a download link via PM

You are still using the first version of Kirby 3 (3.0.0), please update to the latest version.

On a side note, you declare a plugin in a controller, you should move that to a plugin file otherwise it won’t be registered.

Yep. Now it works. Thank you very much!
I downloaded it a while ago…

I have a little sugestion: It would be easyer to see what version we are in, if it would been written somewhere. For example in the name of the kirbyfolder. (kirby_3.0.0)
I saw just saw, how to get this info – but it is not very handy, don’t you think?

But thanks for your great support.

You can see the Kirby version in the Panel, on the Setttings page. Also, you can get the Kirby version via echo $kirby->version(). You can also find it in the composer.json file.

I didn’t expect you to use such an outdated version, so it took me a while to find out that is was not something in your code…:see_no_evil: Anfängerfehler, even after so many years in support :wink:

Oh, by the way, your .htaccess is not in line with the current version either.

1 Like