Search code examples
variablesprestashopsmarty

Prestashop 1.7 - global var doesnt work on CMS page


How can i check language on CMS page?

I use

{if $language.iso_code=='gb'}{/if}

on homepage (domain.com/gb/) and it works, unfortunatelly when i use exact same code on other pages (i.e. domain.com/gb/content/11-test) - it fails. Simply print result of {$language.iso_code} is empty, like all others language related vars... I use shortcodes to include my tpl files (and there is my language related code) into CMS pages.

What should i do now? Debug mode says: "Notice: Undefined index: language"


Solution

  • You can get the $language variable in themes/your_theme/content/cms/page.tpl with a code {if $language.iso_code=='gb'}{/if}. But it will work for all cms pages, so if you need only particular one you can use {if $cms.id}{/if} to detirmine the page.