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>
Mark
  • 1,961
  • 4
  • 16
  • 20

1 Answers1

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>
motanelu
  • 3,945
  • 1
  • 14
  • 21