String as parameter in ezini

Author Message

Petter Arneson

Friday 02 September 2005 7:55:06 am

Why can't I use:

{def $test='../share/locale/nor-NO.ini'}
Test: {$test}
{def $currency_name=ezini('Currency', 'ShortName', $test)}
Currency: {$currency_name}

..when this works fine:

{def $currency_name=ezini('Currency', 'ShortName', '../share/locale/nor-NO.ini')}
Currency: {$currency_name}

When the text produced is the same, why can't I use variables?

www.vzt.no

Kirill Subbotin

Monday 05 September 2005 9:00:01 am

This usually happens when you use template compilation, because ezini gets compiled to just a static value. This is done to increase speed and should work this way.

You can probably get this work by disabling template compilation, but I suggest you to try this:

def $currency_name=ezini('Currency', 'ShortName', 'nor-NO.ini', 'share/locale', true)}

This is a way of dynamic fetching of ini settings, it is still undocumented, but should work in ez publish 3.6 or higher.

And please reply, does it work for you or not ?

Petter Arneson

Monday 05 September 2005 11:21:00 am

Thanks.

The line you wrote worked fine. I'm using v. 3.6.1.

But I still can't get any further with my problem.
I want to fetch the locale settings from RegionalSettings, and then fetch the currency from the specified locale. If someone uses greek as locale, the snippet should get the currency settings from the greek .ini file. What I'm trying to do is calculate a products price in Euro, using the eurofxref extension (which by the way is excellent).


{def $ini_file=ezini('RegionalSettings', 'Locale')|append('.ini')}
{def $currency_short_name=ezini('Currency', 'ShortName', $ini_file)}

{let rates=fetch( 'eurofxref', 'fxref' )}
  Your currency in Euro: {rates.fx.$currency_short_name|110n( 'number' )}
{/let}

www.vzt.no

Kirill Subbotin

Tuesday 06 September 2005 1:10:55 am

You can try to change your second line to this:

{def $currency_short_name=ezini('Currency', 'ShortName', $ini_file, 'share/locale', true)}

Petter Arneson

Tuesday 06 September 2005 2:07:15 am

Jupp, that did the trick!

Thanks Kirill.

www.vzt.no

Christopher Grondahl

Wednesday 15 September 2010 1:50:56 pm

Trying to make Kirill's string work on 3.10 without results. Any changes in how eZ displays site currency on later releases?

Here's the code I'm trying to get going:

{def $ini_file=ezini('RegionalSettings', 'Locale')|append('.ini')}
{def $sitecurrency=ezini('Currency', 'ShortName', $ini_file, 'share/locale', true)}
            
{$sitecurrency}

Chris

ez site: http://www.acem.no

Every day is Groundhog Day

Christopher Grondahl

Wednesday 15 September 2010 2:58:57 pm

A friend helped me out, here's the code that actually works - if it can be of any help to other stuck in the same challenge:

 {def $ini_file=ezini('RegionalSettings', 'Locale')|append('.ini')}
 {def $sitecurrency=ezini('Currency', 'ShortName', '../share/locale/'|append($ini_file), true(), true() )}

Chris

ez site: http://www.acem.no

Every day is Groundhog Day

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 10:41:38
Script start
Timing: Jan 18 2025 10:41:38
Module start 'layout'
Timing: Jan 18 2025 10:41:38
Module start 'content'
Timing: Jan 18 2025 10:41:38
Module end 'content'
Timing: Jan 18 2025 10:41:38
Script end

Main resources:

Total runtime0.6799 sec
Peak memory usage4,096.0000 KB
Database Queries71

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9063152.6250
Module start 'layout' 0.00540.0029 740.531339.4453
Module start 'content' 0.00830.6692 779.9766616.9531
Module end 'content' 0.67740.0017 1,396.929716.1641
Script end 0.6792  1,413.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4473160.0002
Check MTime0.00130.1935160.0001
Mysql Total
Database connection0.00090.131810.0009
Mysqli_queries0.616890.7217710.0087
Looping result0.00070.1061690.0000
Template Total0.644094.720.3220
Template load0.00180.266420.0009
Template processing0.642294.459720.3211
Template load and register function0.00010.018610.0001
states
state_id_array0.00240.354910.0024
state_identifier_array0.00140.201220.0007
Override
Cache load0.00150.2263350.0000
Sytem overhead
Fetch class attribute can translate value0.00090.129130.0003
Fetch class attribute name0.00160.232080.0002
XML
Image XML parsing0.00230.340830.0008
class_abstraction
Instantiating content class attribute0.00000.003090.0000
General
dbfile0.00330.4826160.0002
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 30
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs