0

I want to switch between languages. I wrote a function in the controller. However, only the first switch works. Then I do not want to work. Moreover, for each click magnifies the address for a link that leads to change the language:

contact/switchLanguage/switchLanguage/switchLanguage/en

Code in controller:

public function switchLanguage($language = "")
{
    if ($language == "pl")
    {
        $this->smarty->display('contact.tpl');
    }
    else
    {
        $this->smarty->display('contact_eng.tpl');
    }
}

Code in HTML:

<a href="switchLanguage/pl">Poland</a>
<a href="switchLanguage/en">English</a>
1
  • 1
    The is the problem? Question is not clear. Would you explain. Nov 6, 2014 at 10:21

1 Answer 1

1

Use this code

<a href="<?php echo site_url('switchLanguage/pl);?>">Poland</a>
<a href="<?php echo site_url('switchLanguage/en');?>">English</a>

or simply

<a href="/switchLanguage/pl">Poland</a>
<a href="/switchLanguage/en">English</a>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.