Soheil Gh Posted September 19, 2011 Share Posted September 19, 2011 hello all. i design a theme for prestashop 1.4 . it support both RTL & LTR language i change a few detail in tpl file . so i need to check language is ltr or rtl in tpl file i override classes and controllers in php file to check it such this $language = new Language($cookie->id_lang); if ($language->is_rtl) but i need check in a tpl file someone konow how i do it Link to comment Share on other sites More sharing options...
Soheil Gh Posted September 19, 2011 Author Share Posted September 19, 2011 no one konws how i can check it i try to add a smarty variable in overriden class but it does not work Link to comment Share on other sites More sharing options...
Soheil Gh Posted September 19, 2011 Author Share Posted September 19, 2011 Here is demo of my theme: demo it support both RTL (eg persian) & LTR lang (eg english) in perstashop 1.4 Link to comment Share on other sites More sharing options...
Nuvish Posted April 4, 2013 Share Posted April 4, 2013 (edited) Hello, You can access the current language id by {$cookie->id_lang} in tpl files. I guess if you don't have many languages,you can hardcode what you desire by : {if $cookie->id_lang eq 1} {* English language,therefore LTR *} do english processing here {elseif $cookie->id_lang eq 2} {* persian language,therefore RTL -- remember to adapt id_lang of persian language *} do other processing here {/if} But, if you really need this dynamic : In tpl files,you can have access to all languages present by this global array $languages. It stores all information about the active languages. So,your code might roughly look like that : {foreach from=$languages item=$language} {* i guess you'll want to know which language is active and you'll want to do some processing with that *} {if ($cookie->id_lang eq $language.id_lang) AND $language.is_rtl eq 1} do RTL processing here {else} do LTR here {/if} This should work,but i didn't test anything FYI : $cookie { active cookie } $languages { grabs available languages } This is an old post,but hope it helps someone someday Edited April 4, 2013 by martyn (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