You are here: start » plugin_tutorial_config

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

plugin_tutorial_config [2012/10/05 19:51]
Christoph M. Becker [Plugin Tutorial: Configuration]
plugin_tutorial_config [2018/10/26 15:33]
Line 1: Line 1:
-====== 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. 
-<​code=php>​ 
-<?php 
- 
-$plugin_cf['​visitors_online'​]['​duration'​]="​5";​ 
- 
-?> 
-</​code>​ 
-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 
-<​code=php>​define('​VISITORS_DURATION',​ $plugin_cf['​visitors_online'​]['​duration'​]*60);</​code>​ 
- 
-===== Important Rules ===== 
- 
-  * Never ever modify $c, when ($adm && $edit). OTOH: if you need to rely on unmodified $c, make sure that ($adm && $edit). 
- 
-<< [[plugin_tutorial_i18n|Internationalization]] | [[plugin_tutorial_admin|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