Adding and using configuration settings: Difference between revisions
Appearance
m typo |
expanding a bit on the example |
||
| Line 10: | Line 10: | ||
To retrieve variables, either ones you've added or existing ones, use the atkconfig() function and supply the name of the variable you want. | To retrieve variables, either ones you've added or existing ones, use the atkconfig() function and supply the name of the variable you want. | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
atkconfig("foo"); | $my_foo = atkconfig("foo"); // now $my_foo = 'bar'; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This would return the variable $config_foo from the config file. Arrays can also be handled in this way. The atkconfig() call can be used from within your module and attribute classes. | This would return the variable $config_foo from the config file. Arrays can also be handled in this way. The atkconfig() call can be used from within your module and attribute classes. | ||
Revision as of 16:28, 3 September 2008
|
ATK Howto: Adding and using configuration settings
|
Adding a new configuration setting can be very useful, and in ATK its very easy. In config.inc.php, just add a line which sets the variable, e.g.:
$config_foo = 'bar';
The variable name must start with $config.
To retrieve variables, either ones you've added or existing ones, use the atkconfig() function and supply the name of the variable you want.
$my_foo = atkconfig("foo"); // now $my_foo = 'bar';
This would return the variable $config_foo from the config file. Arrays can also be handled in this way. The atkconfig() call can be used from within your module and attribute classes.