• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..Today-

action/H16-May-2018-239164

conf/H16-May-2018-84

exe/H16-May-2018-225152

inc/H16-May-2018-11357

READMEH A D24-Feb-20133.9 KiB9060

README

1====== templateconfhelper Plugin ======
2
3various functions to help with template management.
4  * template inheritance with cascade [[#inheritance]]
5  * custom css.php with inheritance [[#preload]]
6  * userstyle [[#templateaction]]
7
8===== TemplateAction =====
9changes template based on users Selection via GET and saves it in the Session.
10
11==== parameter ====
12
13  * $_GET[utpl]  /^[\w-]+$/ - override template
14
15==== functions ====
16
17  * get_user( $var=false ) - get utpl from session
18  * save_session( $var, $false ) - save utpl to session
19  * save_user( $var, $val ) - #DUMMY
20  * tpl_switch( $tpl ) - change style after init.php has been run
21  * tpl_loadconfig( $tpl ) - reload config for template, called on switch
22
23===== FetchAction =====
24
25uses FETCH_MEDIA_STATUS event to hook into fetch.php. This allows to have template files outside of webroot.
26
27==== parameter ====
28
29  * $_GET[mode]  styleimg - trigger
30  * $_GET[template /^[\w-]*$/ - template dir to search for the file
31a nginx rewrite rule to fix path used in templates
32  rewrite ^/lib/tpl/((.*)/)?images/(.*)      /lib/exe/fetch.php?mode=styleimg&media=$3&template=$2 last;
33
34===== inheritance =====
35
36The custom css.php and the functions in //inc/template.php// use following new config settings to look up templatefiles. Files that dont exist in the active template are choosen from the next template in this order:
37
38  * template, dokuwiki template setting possibly overwritten by template switch
39  * default_tpl, dokuwiki template setting
40  * base_tpl, fallback template
41
42For the main.php the default is hardcoded in dokuwiki.php. So for templates to overwrite the main.php they have to exist in the dokuwiki //lib/tpl/// directory. Fallback is always //lib/tpl/default///. This is a security feature as without a special template making use of eg the tpl_include function no php code from the following cascade path is interpreted. (I think)
43
44Cascade Path is an extension to the cascade config values in dokuwiki init. It can be set in preload.php and allows to read templates from pathes outside dokuwiki code. E.g. per domain in farming environments.
45
46Example cascade path for inc/preload.php
47
48  $version    = '/dokuwiki/'
49  $farmdir    = "$farmbasedir/domains/$animal/";
50
51  $config_cascade['template_dir'] = array(    // used in templateconfig plugin
52      'default' => array( $farmbasedir.'/extension/tpl/', $farmbasedir.$version.'lib/tpl/' ),
53      'local' => array( $farmdir.'tpl/' ),
54      #'protected' => array( $farmbasedir.'/extension/tpl_protected/' ),
55    );
56
57to allow animals to overwrite template php files a main.php like this can be used in the default_tpl or base_tpl in dokuwiki //lib/tpl/// directory. It will check the cascade path for a main.php in the active template.
58<file php main.php>
59  <?php
60  tpl_include( 'main.php' );
61</file>
62
63===== preload =====
64
65This is a rather creative apporach to hook into css.php. The templateaction plugin class deffinition includes //inc/preload.php//. Here css.php calls are intercepted and the custom css.php from the plugins //exe// directory is loaded.
66
67If the template_path cascade config has not been set. Defaults are made up for a standard dokuwiki setup.
68
69===== helper =====
70
71==== confutils ====
72  * getConfigPath( $type, $file ) - find file in cascade_config[$type]
73
74==== template ====
75  * tpl_include( $file, $t=false ) - use getConfigPath to include file from cascade_config['template_path'], checks templates $t, default_tpl and base_tpl
76  * ... some undocumented and likely to change functions for use in templates
77
78==== css ====
79include style.ini and css files based on inheritance. Makes use of default_tpl, base_tpl and getConfigPath( )
80change cache rules to see changes on cascade path.
81
82===== changes =====
83
84==== release0.1 - Sat Mar 5 2011 ====
85  * public functions marked public now for free software reasons
86  * templateconfig cascade removed, should go into preload or seperate plugin
87  * some inheritance dokumentation
88  * new config setting for base_tpl
89
90