Jump to content

Switch-language-button (front-end)


Recommended Posts


in the upper right corner of my page I (php noob) want an "EN" button when a user enters the website. If he/she wants to switch to english, he/she can hit the "EN" button and the content + navbar is in english.

What I have:

- I installed the language and multi language modules.

- I switched the content field (textarea) to multi-language.

So far the language is linked with the account settings. So in my "test-account" user's account, if I change from default to english, the website is in english - good.

But I don't have a login system in the front-end and I want this for guest users who don't have accounts. How can I trigger this?


Thank you in advance.

Link to comment
Share on other sites

4 hours ago, Marcel said:

How can I trigger this?

As long as the language switcher is concerned: if you only have two languages, then you can do this in your template file:

<a href="<?= $page->localUrl($languages->findOther()->first()) ?>"><?= $user->language->name == "default" ? "EN" : "HU" ?></a>

Regarding translatable strings, I recommend this method (but in the forum you can certainly find other methods too in order to get inspiration from) :


  • Like 2
Link to comment
Share on other sites

Here you go, pwired's super language switcher:

$i = 1;
foreach($languages as $language) {
$var[$i] = $page->localUrl($language);
echo "<li>" . "<a href=" . '"' . $var[3] . '"' . ">" . "Deutsch" . "</a>" . "</li>";
echo "<li>" . "<a href=" . '"' . $var[2] . '"' . ">" . "English" . "</a>" . "</li>";
echo "<li>" . "<a href=" . '"' . $var[1] . '"' . ">" . "Español" . "</a>" . "</li>";

Feel free to modify for your own needs, and beautify <ul>, <li> and <a> with your own custom css

Here is a recommended read not to fall into unexpected not working language urls:




  • Like 2
Link to comment
Share on other sites

Has anyone an idea how I can access the language tab of a field? And is this even possible?

When I try the following I just get the account related output (language):


But I would like to have like the particular language like


I don't find the right part in the api


thank you in advance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...