You are here: start » plugin_tutorial_config

Plugin Tutorial: Configuration

It's good practise not to hardcode any values that are likely to change directly to your programm code. So in index.php VISITORS_DURATION was defined as constant, so it could easily be spotted and changed. To make changing this setting even more convenient for users, you can put it to a configuration file.

So create a folder config/ in your plugin's folder, and create a file config.php with the following contents and save it as UTF-8 without BOM.

<?php
 
$plugin_cf['visitors_online']['duration']="5";
 
?>

This is very similar to the language file. Note that the configuration variable is called $plugin_cf instead of $plugin_tx.

To use the config variable change line 7 of index.php to

define('VISITORS_DURATION', $plugin_cf['visitors_online']['duration']*60);

TODO: help texts

Important Rules

  • Never ever modify $c, when ($adm && $edit). OTOH: if you need to rely on unmodified $c, make sure that ($adm && $edit).

« Internationalization | Administration »

 
You are here: start » plugin_tutorial_config
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Valid XHTML 1.0 Valid CSS Driven by DokuWiki