This template is called automatically on every object after it is instantiated. It is also called on each objects parents once. This allows you to do some housekeeping like loading libraries, configuring them and setting up variables to be used later.

The config.ini template can set a special array, called $arConfig. Anything put into this array, will automatically be available on any object under the current one in the Ariadne content tree. You can retrieve these values through the loadUserConfig() method or ar::acquire. Other config.ini templates run on objects under the current one can override these values for their children.

You can also load a library, so it is available for all children of the current object. You do this through the loadLibrary() method.

The config.ini template will always run, regardless of a users access grants. Also, it runs before Ariadne is completely setup, since it is part of this process. So you must never save objects, generate output or change the (persistent) state of Ariadne in another way.


loadLibrary('forms', '/lib/forms/');
loadLibrary(ARUNNAMED, '/lib/layout/');

$arConfig = getvar('arConfig');
$arConfig['settings']['forms'] = array(
'method' => 'POST',
'action' => ''
ar::putvar('arConfig', $arConfig);

This config.ini template instructs Ariadne to load the templates defined at /lib/forms/ and make them available with the prefix 'forms:'. This means that if a template 'view.html' is defined at /lib/forms/, then any template can call it with the name 'forms:view.html'.

Next the templates at /lib/layout/ are loaded, without any prefix – as signified by the ARUNNAMED constant. This means that these templates are available as if they were defined on the current object.

Finally the template stores a setting in the $arConfig array, in this case for later use with the forms library. The forms library can retrieve this value as follows:

$config = loadUserConfig()['settings']['forms'];
$action = $config['action'];

Or in Ariadne > 2.7.5 you can do:

$action = ar::acquire('settings.forms.action');

Values set in the $arConfig array and loaded through loadUserConfig() (or ar::acquire) are guaranteed to be the value set in the nearest parents' config.ini template. If you simply set a variable using putvar(), this variable will also be available in the children through getvar(), but if more than one config.ini sets a value for this variable, there is no guarantee which value it will be. The last putvar() overrides any previous calls. It is simply a global variable.

Using the $arConfig array and loadUserConfig() you create variable which are specific for the child content tree. This mechanism is also known as 'acquisition'. Templates run on objects below the current one can 'acquire' values from the parent.

Because the correct working of the config.ini template is vital for Ariadne, when saving this template Ariadne adds some additional checking. If the template has a syntax error or generates output of any kind Ariadne will refuse to save it. You must first fix the problem.