DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:templateconfhelper

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:templateconfhelper [2015-05-16 15:55] sfplugin:templateconfhelper [2018-06-06 00:22] (current) Klap-in
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: template switching and inheritance+description: Template switching and inheritance
 author     : Samuel Fischer author     : Samuel Fischer
 email      : sf@notomorrow.de email      : sf@notomorrow.de
Line 12: Line 12:
 similar    : loadskin, multitemplate_styleman similar    : loadskin, multitemplate_styleman
 tags       : template farm tags       : template farm
-downloadurl: http://r.notomorrow.de/dokuwiki-plugin-templateconfhelper/pkg/templateconfhelper-develop.tgz+ 
 +downloadurl: https://github.com/samfisch/dokuwiki-plugin-templateconfhelper/zipball/master
 bugtracker : https://github.com/samfisch/dokuwiki-plugin-templateconfhelper/issues bugtracker : https://github.com/samfisch/dokuwiki-plugin-templateconfhelper/issues
 sourcerepo : https://github.com/samfisch/dokuwiki-plugin-templateconfhelper sourcerepo : https://github.com/samfisch/dokuwiki-plugin-templateconfhelper
 +donationurl: 
 +
 +screenshot_img: 
 +
 ---- ----
 +
 ===== Installation ===== ===== Installation =====
  
-:!: This plugin helps developing and managing templates. It does not add any functioanlity by its own.+:!: This plugin helps developing and managing templates. It does not add any functionality by its own.
  
 :!: This is a beta release. The functions included or their use might be a security risk :!: This is a beta release. The functions included or their use might be a security risk
  
-you can install the plugin using the [[plugin:plugin|Plugin Manager]] using above download url or download a release from my repohttp://m3.notomorrow.de/public/repos/+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. 
 + 
 +  * https://github.com/samfisch/dokuwiki-plugin-templateconfhelper 
 + 
 +Or checkout the source on GitHub:
  
-or checkout the source on github: 
   git clone git://github.com/samfisch/dokuwiki-plugin-templateconfhelper.git templateconfhelper   git clone git://github.com/samfisch/dokuwiki-plugin-templateconfhelper.git templateconfhelper
  
-===== features =====+===== Features =====
  
   * template inheritance, templates can reference php and style files from other templates -- [[#inheritance]]   * template inheritance, templates can reference php and style files from other templates -- [[#inheritance]]
-  * template switcher action plugin, later version might include template tags or user-settings-page extension --[[#templateaction]]+  * template switcher action plugin, later version might include template tags or user-settings-page extension -- [[#templateaction]]
   * template images via fetch.php -- [[#fetchaction]]   * template images via fetch.php -- [[#fetchaction]]
   * cascading template path, templates can be stored outside dokuwiki directory if you use [[devel:preload|preload]]   * cascading template path, templates can be stored outside dokuwiki directory if you use [[devel:preload|preload]]
  
-===== examples =====+===== Examples =====
  
 An example template making use of css iheritance could look like this: An example template making use of css iheritance could look like this:
 {{ http://m3.notomorrow.de/public/repos/dokuwiki/plugins/dokuwiki-plugin-templateconfhelper-example.png?400|example tpl with default base_tpl}} {{ http://m3.notomorrow.de/public/repos/dokuwiki/plugins/dokuwiki-plugin-templateconfhelper-example.png?400|example tpl with default base_tpl}}
-<file ini style.ini>+ 
 +<file css style.ini>
 [stylesheets] [stylesheets]
 layout.css     = screen layout.css     = screen
Line 65: Line 75:
 </file> </file>
  
 +===== Templateaction =====
  
 +Changes template based on users Selection via GET and saves it in the Session.
  
 +==== Parameter ====
  
-===== templateaction ===== +  * ''%%$_GET[utpl]  /^[\w-]+$/%%'' -- override template
-changes template based on users Selection via GET and saves it in the Session.+
  
-==== parameter ==== +==== Functions ====
-  * $_GET[utpl]  /^[\w-]+$/ - override template+
  
-==== functions ==== +  ''%%get_user( $var=false )%%'' -- get utpl from session 
-  * get_user( $var=false ) - get utpl from session +  * ''%%save_session( $var, $false )%%'' -- save utpl to session 
-  * save_session( $var, $false ) - save utpl to session +  * ''%%save_user( $var, $val )%%'' -- #DUMMY 
-  * save_user( $var, $val ) - #DUMMY +  * ''%%tpl_switch( $tpl )%%'' -- change style after init.php has been run 
-  * tpl_switch( $tpl ) - change style after init.php has been run +  * ''%%tpl_loadconfig( $tpl )%%'' -- reload config for template, called on switch
-  * tpl_loadconfig( $tpl ) - reload config for template, called on switch+
  
-===== fetchaction ===== +===== Fetchaction ===== 
-uses FETCH_MEDIA_STATUS event to hook into fetch.php. This allows to have template files outside of webroot.+ 
 +Uses FETCH_MEDIA_STATUS event to hook into fetch.php. This allows to have template files outside of webroot. 
 + 
 +==== Parameter ==== 
 + 
 +  * ''%%$_GET[mode]  styleimg%%'' -- trigger 
 +  * ''%%$_GET[template /^[\w-]*$/%%'' -- template dir to search for the file
  
-==== parameter ==== 
-  * $_GET[mode]  styleimg - trigger 
-  * $_GET[template /^[\w-]*$/ - template dir to search for the file 
 a nginx rewrite rule to fix path used in templates a nginx rewrite rule to fix path used in templates
 +
   rewrite ^/lib/tpl/((.*)/)?images/(.*)      /lib/exe/fetch.php?mode=styleimg&media=$3&template=$2 last;   rewrite ^/lib/tpl/((.*)/)?images/(.*)      /lib/exe/fetch.php?mode=styleimg&media=$3&template=$2 last;
 +
 or with nicer path or with nicer path
 +
   rewrite ^/_img/((.*)/)?(.*)        /lib/exe/fetch.php?mode=styleimg&media=$3&template=$2 last;   rewrite ^/_img/((.*)/)?(.*)        /lib/exe/fetch.php?mode=styleimg&media=$3&template=$2 last;
  
-===== inheritance =====+===== Inheritance ===== 
 + 
 +The custom ''css.php'' and the functions in ''inc/template.php'' use following config settings to look up templatefiles. Files that dont exist in the active template are choosen from the next template in this order:
  
-The custom css.php and the functions in //inc/template.php// use following config settings to look up templatefiles. Files that dont exist in the active template are choosen from the next template in this order: 
   * template, existing dokuwiki template setting possibly overwritten by template switch   * template, existing dokuwiki template setting possibly overwritten by template switch
-  * default_tpl, automaticaly set dokuwiki template setting  +  * ''default_tpl'', automaticaly set dokuwiki template setting  
-  * base_tpl, new config setting for fallback template +  * ''base_tpl'', new config setting for fallback template 
  
-For the main.php the default is hardcoded in dokuwiki. 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)+For the ''main.php'' the default is hardcoded in DokuWiki. 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 e.g. the ''tpl_include'' function no php code from the following cascade path is interpreted. (I think.)
  
-==== configuration ==== +==== Configuration ====
-The base_tpl can be configured using the DokuWiki configuration manager available in the admin menu.+
  
-''base_tpl'' | The default template which is used if the file was not found in the page or user template |+The ''base_tpl'' can be configured using the DokuWiki configuration manager available in the admin menu.
  
-Cascade Path is an extension to the cascade config values in dokuwiki init. It can be set in preload.php. The new template_path setting allows to read templates from pathes outside dokuwiki code. E.g. per domain in farming environments.+^ ''base_tpl'' | The default template which is used if the file was not found in the page or user template  |
  
-The plugin has a hardcoded cascade path wich is used if the //$cascade_path['template_dir']// setting is empty as it is in a default install. +Cascade Path is an extension to the cascade config values in dokuwiki initIt can be set in ''preload.php''The new ''template_path'' setting allows to read templates from pathes outside dokuwiki code. E.g. per domain in farming environments.
-  $config_cascade['template_dir'] = array(    // used in confutils      +
-    'default=> array( dirname( DOKU_TPLINC ).'/), +
-  );+
  
-==== example ====+The plugin has a hardcoded cascade path wich is used if the ''%%$cascade_path['template_dir']%%'' setting is empty as it is in a default install.
  
-Example cascade path for inc/preload.php +<code php> 
-  $version    = '/dokuwiki/' +$config_cascade['template_dir'] = array(    // used in confutils 
-  $farmdir    = "$farmbasedir/domains/$animal/";+  'default' => array( dirname( DOKU_TPLINC ).'/' ), 
 +); 
 +</code> 
 + 
 +==== Example ==== 
 + 
 +Example cascade path for ''inc/preload.php'' 
 + 
 +<code php> 
 +$version    = '/dokuwiki/' 
 +$farmdir    = "$farmbasedir/domains/$animal/"; 
 + 
 +$config_cascade['template_dir'] = array(    // used in templateconfig plugin 
 +    'default' => array( $farmbasedir.'/extension/tpl/', $farmbasedir.$version.'lib/tpl/' ), 
 +    'local' => array( $farmdir.'tpl/' ), 
 +    #'protected' => array( $farmbasedir.'/extension/tpl_protected/' ), 
 +  ); 
 +</code>
  
-  $config_cascade['template_dir'] = array(    // used in templateconfig plugin 
-      'default' => array( $farmbasedir.'/extension/tpl/', $farmbasedir.$version.'lib/tpl/' ), 
-      'local' => array( $farmdir.'tpl/' ), 
-      #'protected' => array( $farmbasedir.'/extension/tpl_protected/' ), 
-    ); 
 {{ http://m3.notomorrow.de/public/repos/dokuwiki/plugins/dokuwiki-plugin-templateconfhelper-path.png?400|example getConfigPath debugging output}} {{ http://m3.notomorrow.de/public/repos/dokuwiki/plugins/dokuwiki-plugin-templateconfhelper-path.png?400|example getConfigPath debugging output}}
-to 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.+ 
 +To 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. 
 <file php main.php> <file php main.php>
-  <?php +<?php 
-  tpl_include( 'main.php' );+tpl_include( 'main.php' );
 </file> </file>
  
-===== preload =====+===== Preload =====
  
-This 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.+This 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.
  
-If the template_path cascade config has not been set. Defaults are made up for a standard dokuwiki setup.+If the ''template_path'' cascade config has not been set. Defaults are made up for a standard dokuwiki setup.
  
-===== helper =====+===== Helper =====
  
-==== confutils ==== +==== ConfUtils ====
-  * getConfigPath( $type, $file ) - find file in cascade_config[$type]+
  
-==== template ==== +  * ''%%getConfigPath( $type, $file )%%'' -- find file in ''cascade_config[$type]'' 
-  * tpl_include( $file, $t=false ) - use getConfigPath to include file from cascade_config['template_path'], checks templates $t, default_tpl and base_tpl+ 
 +==== Template ==== 
 + 
 +  * ''%%tpl_include( $file, $t=false )%%'' -- use ''getConfigPath'' to include file from ''cascade_config['template_path']'', checks templates ''$t''''default_tpl'' and ''base_tpl''
   * ... some undocumented and likely to change functions for use in templates     * ... some undocumented and likely to change functions for use in templates  
  
-==== css ==== +==== CSS ==== 
-include style.ini and css files based on inheritance. Makes use of default_tpl, base_tpl and getConfigPath( )+ 
 +Include style.ini and css files based on inheritance. Makes use of ''default_tpl''''base_tpl'' and ''getConfigPath( )''
 + 
 +===== Changes ===== 
 + 
 +{{rss>https://github.com/samfisch/dokuwiki-plugin-templateconfhelper/commits/master.atom date}} 
 + 
 +===== FAQ =====
  
-===== changes ===== +===== ToDo =====
-{{rss>https://github.com/samfisch/dokuwiki-plugin-templateconfhelper/commits/master.atom 3 date}}+
  
-===== faq =====+  * Exclude or document template helper functions 
 +  * Add template switcher for user settings 
 +  * Publish some templates
  
-===== todo ===== +===== Discussion =====
-  * exclude or document template helper functions +
-  * add template switcher for user settings +
-  * publish some templates+
  
-===== discussion ===== +Let me know if you use this or not. I ll try to provide some of my templates that make use of this functions.  --- [[user>sf|sf]] //2011/03/06 16:21//
-  * let me know if you use this or not. I ll try to provide some of my templates that make use of this functions.  --- [[user>sf|sf]] //2011/03/06 16:21//+
  
plugin/templateconfhelper.1431784545.txt.gz · Last modified: 2015-05-16 15:55 by sf

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki