Forums / General / String as parameter in ezini

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

eZ debug

Timing: Jan 18 2025 02:53:05
Script start
Timing: Jan 18 2025 02:53:05
Module start 'content'
Timing: Jan 18 2025 02:53:06
Module end 'content'
Timing: Jan 18 2025 02:53:07
Script end

Main resources:

Total runtime1.4900 sec
Peak memory usage4,096.0000 KB
Database Queries208

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 588.8203180.8438
Module start 'content' 0.00661.3693 769.6641622.0313
Module end 'content' 1.37590.1141 1,391.6953341.0703
Script end 1.4900  1,732.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00480.3213210.0002
Check MTime0.00190.1255210.0001
Mysql Total
Database connection0.00080.053310.0008
Mysqli_queries1.403694.19922080.0067
Looping result0.00190.13002060.0000
Template Total1.424095.620.7120
Template load0.00240.158720.0012
Template processing1.421795.411720.7108
Template load and register function0.00020.014110.0002
states
state_id_array0.00800.538410.0080
state_identifier_array0.00170.116120.0009
Override
Cache load0.00200.1355350.0001
Sytem overhead
Fetch class attribute can translate value0.00130.086040.0003
Fetch class attribute name0.00150.097880.0002
XML
Image XML parsing0.00090.062940.0002
class_abstraction
Instantiating content class attribute0.00000.001190.0000
General
dbfile0.00860.5749270.0003
String conversion0.00000.000530.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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