Jump to content

Language quickchange in Back Office


Recommended Posts



Site requires some more controls.
Rather than going to the settings and changing the language there, I'd like to have a language switch in a different place.

I've decided on getting the languages in the header.tpl.

So, I've worked out some stuff like this:

                            <a href="?change_lang=4">Lang4</a> 
                            <a href="?change_lang=1">Lang1</a> 
                            <a href="?change_lang=6">Lang6</a> 
                            <a href="?change_lang=5">Lang5</a>

I felt lazy and just updated the admin's index.php file to have this:

if(isset($_GET['change_lang'])) {
    $_GET['id_lang'] = $_GET['change_lang'];

The language changes at first, BUT it is not saved.

I've skimmed through the methods and they should do that stuff themselves as switchLanguage uses $_GET['id_lang'] and puts it in the cookie. And, well, the second one is just a guess that I might also need it too.

Does not seem to work for me now.


Thanks for the help! :)




Link to comment
Share on other sites


why not to use


method than links like <a href="?change_lang=5"> and function with Tools object?

much easier and will work. always :)

Link to comment
Share on other sites

You can override classes file ../classes/controller/AdminController.php in function postProcess() and function initHeader()

something like this ...

class AdminController extends AdminControllerCore
    public function postProcess()
        if(Tools::isSubmit('changeLang')) {
            $context = Context::getContext();
            $employee = new Employee($context->employee->id);
            if($employee->id_lang != Tools::getValue('id_lang')) {
                $employee->id_lang = Tools::getValue('id_lang');
                    $this->redirect_after = self::$currentIndex.'&token='.$this->token;
    public function initHeader()

            'languages' => Language::getLanguages(false),
            'thisIndex' => self::$currentIndex.'&token='.$this->token

And then modify admin theme file header.tpl within <ul id="employee_links"> to add :

{foreach from=$languages item=lang}
    {if $iso_user != $lang.iso_code}
          <li><a href="{$thisIndex}&id_lang={$lang.id_lang}&changeLang">{$lang.iso_code}</a></li>
          <li class="separator"> </li>
Edited by gonebdg - webindoshop.com (see edit history)
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
  • Create New...