Search code examples
twigopencartopencart-3

How to move language selector in OpenCart


How to move language selector from "common.header" to anywhere else?

Once there are two or more languages on the website - a language selector begins to appear in the header section of the website, represented by {{ language }} twig variable.

If I cut

{{ language }}

from the template - language selector disappears. That is expected.

If I place it anywhere else outside common.header twig template - it doesn't appear.

It's not a css thing, the code just doesn't get parsed. I want to move it to footer but I can't seem to pinpoint the source of the problem.


Solution

  • If you want to show it in footer, edit this file:

    catalog\controller\common\footer.php
    

    Find:

    return $this->load->view('common/footer', $data);
    

    Add before it:

    $data['language'] = $this->load->controller('common/language');
    

    Now you can use it in footer.twig:

    {{ language }}
    

    You may need to clear modifications cache and theme caches.