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

[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 :)

eZ debug

Timing: Jan 30 2025 16:40:26
Script start
Timing: Jan 30 2025 16:40:26
Module start 'content'
Timing: Jan 30 2025 16:40:26
Module end 'content'
Timing: Jan 30 2025 16:40:26
Script end

Main resources:

Total runtime0.2210 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 588.0703370.2813
Module start 'content' 0.00710.0147 958.35161,005.6719
Module end 'content' 0.02180.1992 1,964.02343,894.5391
Script end 0.2209  5,858.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00462.0784200.0002
Check MTime0.00160.7046200.0001
Mysql Total
Database connection0.00070.336210.0007
Mysqli_queries0.119654.12411410.0008
Looping result0.00170.76811390.0000
Template Total0.198689.910.1986
Template load0.00110.491410.0011
Template processing0.197689.384710.1976
Override
Cache load0.00080.348910.0008
Sytem overhead
Fetch class attribute can translate value0.00200.915310.0020
XML
Image XML parsing0.00030.118110.0003
General
dbfile0.00904.0749200.0005
String conversion0.00000.002630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

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

Time used to render debug report: 0.0002 secs