I was wondering if there was a better way to translate link slugs, by that I mean let’s say I have links in my footer that would link to a specific page, I would need to insert text into the url that would change depending on the selected language to get the proper link. This way works but I can sometimes end up with 30-40 different variables that need to be translated and really messes up my translation module.
Is there a way to do this via some sort of PHP or Kirby code? Such as retrieving a page slug?
Example, if I want to get the contact page’s slug which is saved in my templates as contact.php, could I get the right slug depending on the active language?
I hope it’s clear but it’s sort of hard to explain.
So the pages are translated via the changeUrl like you said which is fine. But if I need to fetch that URL to add into a href tag for a footer link, I need to add a <?php echo t('example-variable') ?> into the url field href=“/<?php echo t('example-variable') ?>” to fetch the translated url.
Like I said, it works but it adds dozens and dozens of additional translation variables that I would not need to add otherwise.
How would I go about writing this code in a href tag? My footer is called via a snippet, and the url for the links in the footer should call the right page url no matter what active page the user is on.
I’m not very good at PHP so I will need a little help writing the code, but if I want to retrieve the translated url automatically for let’s say my contact page which is named contact.php in my template, would the code look something like this: