rtvt Posted June 25, 2020 Share Posted June 25, 2020 Hello, what is the best way to call {$urls.base_url} from .tpl but depend on language? So if there only one language it should return shop.com/ but if there is 2 or more langs - it should return iso of current lang shop.com/en/ for example. Link to comment Share on other sites More sharing options...
rtvt Posted July 9, 2020 Author Share Posted July 9, 2020 On 7/3/2020 at 7:18 PM, ndiaga said: Hi, Try to use : {assign var=context value=Context::getContext()} {assign var=iso_lang value=$context->language->iso_code} <! then you can do --> {$urls.base_url}$iso_lang thank you, but It's not solve the main problem: If you have only one language in shop - for example english. Then {$urls.base_url}{$iso_lang}example.html generates wrong link: shop.com/en/example.html while the real link with shop with one languge will be shop.com/example.html Link to comment Share on other sites More sharing options...
rtvt Posted July 15, 2020 Author Share Posted July 15, 2020 I did it in php by checking Language::getLanguages , but it would be better if there will be some global variable like it was {languages} in ps1.6 to call in templates. Link to comment Share on other sites More sharing options...
ibisal Posted May 23, 2021 Share Posted May 23, 2021 (edited) themes/classic/templates/_partials/header.tpl themes/classic/templates/checkout/_partials/header.tpl This worked for me: {assign var=context value=Context::getContext()} {assign var=iso_lang value=$context->language->iso_code} and the URL: <a href="{$urls.base_url}{$iso_lang}/"> Dont forget to clear the prestashop cache! Cheers! Edited May 23, 2021 by ibisal (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now