[SOLVED] How do I get the language in a node template?

Author Message

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).

Knut Urdalen

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

Knut Urdalen

Tuesday 13 November 2007 1:44:12 am

Thanks :)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:42:20
Script start
Timing: Jan 18 2025 11:42:20
Module start 'layout'
Timing: Jan 18 2025 11:42:20
Module start 'content'
Timing: Jan 18 2025 11:42:20
Module end 'content'
Timing: Jan 18 2025 11:42:20
Script end

Main resources:

Total runtime0.0219 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0101 588.0391152.6406
Module start 'layout' 0.01010.0038 740.679739.4922
Module start 'content' 0.01390.0054 780.171993.4609
Module end 'content' 0.01930.0026 873.632834.3047
Script end 0.0219  907.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003415.4180140.0002
Check MTime0.00146.2452140.0001
Mysql Total
Database connection0.00188.421610.0018
Mysqli_queries0.003415.544330.0011
Looping result0.00000.095810.0000
Template Total0.00209.010.0020
Template load0.00125.548410.0012
Template processing0.00083.429610.0008
Override
Cache load0.00094.256010.0009
General
dbfile0.00041.849880.0001
String conversion0.00000.050140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs