Templates : conditions on language

More
13 years 6 days ago #20448 by kursus
Hi all,

I would like to know if it is possible to add a condition a a template depending on the active language. (if lang=en then..)

Thanks a lot

Please Log in or Create an account to join the conversation.

More
13 years 6 days ago #20449 by krapaic
mmm try something like this
Code:
$lg =& JFactory::getLanguage(); if ($lang->getName()=="Italian") { $this->loadTemplate("it"); // supposing you are in item.php // and you create a item_it.php file // containing the language template for italian } else { // normal template }

Please Log in or Create an account to join the conversation.

More
13 years 6 days ago #20470 by ggppdk
Yes but i think this will give the currently default frontend language, better use this:
Code:
$lang = JRequest::getWord('lang', '' ); if(empty($lang)){ $langFactory= JFactory::getLanguage(); $tagLang = $langFactory->getTag(); $lang = substr($tagLang ,0,2); } if (in_array($lang, array("it","de","fr") ) { $this->loadTemplate($lang); // supposing you are in item.php // and you create a item_it.php file // containing the language template for italian } else { //normal template }

krapaic, nice idea about using the :
$this->loadTemplate(...);
it makes it more consistent, i would have forgotten to mention it.

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
13 years 1 day ago #20558 by kursus
Hi,

Thanks a lot for your answers it, went great ;)

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.405 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline