Forums / General / [SOLVED] How do I get the language in a node template?
Knut Urdalen
Monday 05 November 2007 4:19:12 am
I have a template for a custom node where I need to load locale specific graphics (which contains locale specific text). I have my graphics in folders representing the site access ("images/nor/*" and "images/eng/*" in my custom design).
In a page layout I can use:
{def $locale = $access_type.name}
to do this. (ref http://ez.no/doc/ez_publish/technical_manual/3_10/templates/the_pagelayout/variables_in_pagelayout)
Is there a solution to get the same value within the context of a node template?
I read the docs, but could find a proper solution here:http://ez.no/doc/ez_publish/technical_manual/3_10/templates/information_extraction/outputting_node_and_object_data
The graphics does not related to any specific attributes of the node, I just need the current language or siteaccess (since that's the same thing in my setup).
Tuesday 13 November 2007 12:02:20 am
Is there a solution to this?
Xavier Serna
Tuesday 13 November 2007 1:11:10 am
Hi Knut,
to fetch the current locale from a node template you can simply do this:
{def $locale = ezini( 'RegionalSettings', 'Locale', 'site.ini' )}
and you will get the current locale string in the usual form (language-COUNTRY) so then, splitting the locale string by - you can get the current language used.
hth!
-- Xavier Serna eZ Publish Certified Developer Departament de Software Microblau S.L. - http://www.microblau.net +34 937 466 205
Tuesday 13 November 2007 1:44:12 am
Thanks :)