Skip to the content
Documentation

ezini

No ratings yet

Summary

Provides read access to settings in the configuration files.

Usage

ezini( section, variable [, ini file] )

Parameters

Name Type Description Required
section string Section to read value from. Yes.
variable string The name of the directive that should be accessed. Yes.
ini file string The target configuration file (default is "site.ini"). No.

Returns

A string containing the value of a configuration setting.

Description

This operator makes it possible to access the settings in the configuration ("*.ini") files.

Examples

Example 1

{if eq(ezini( 'SomeSettings', 'Test', 'example.ini' ), 'hello' )}
    [...display something...]
{else}
    [...display something else...]
{/if}

Conditional branching based on an configuration setting.

Contributors

Comments (3 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. in 3.9

    VaL ·

    Now, you can use ezini_hasvariable() like
    For example:

    ezini_hasvariable( 'URL', 'URL', 'my.site' )
    =
    ezini( 'URL', 'URL', 'my.ini',,,'hasVariable' )
    ezini( <BlockName>, <SettingName>, <FileName>,
           <IniPath>, <Should we put implementation to cache file?: 'inCache' or true()>,
           <Should we check for existence: 'hasVariable' or true()> )

    When compilation of tpl is enabled:

    ezini( 'URL', 'URL', 'my.ini',, 'inCache')
    =
    ezini( 'URL', 'URL', 'my.ini',, true())

    => if ini variable doesn't exist warnings will not be shown
    http://ez.no/bugs/view/7449

  2. 4th parameter

    Vincent Lepot @ Smile.fr ·

    You should add in this document the fourth parameter which is not documented but implemented !
    ezini( section, variable [, ini file [, dynamic] ] )
    If dynamic = true, the value will be dynamically retrieved from ini file. Else, it will be retrieved during template compilation and will be hard coded in the compiled template.

    1. Re: 4th parameter

      Vincent Lepot @ Smile.fr ·

      Sorry, I'm mistaken :
      ezini( section, variable [, ini file [, ini path [, dynamic] ] ] )
      If you don't need 'ini path' to be set, you can specify false()

Comments

Add a comment

Comments are read by a moderator before they appear.