It's better when it's simple

User Tools

Site Tools


DokuWiki Plugin: multitemplate_styleman

Compatible with DokuWiki

2008-05-05, 2006-11-06, 2007-05-24, 2007-06-26b

plugin Solves the problem with style.ini and the MultiTemplate.

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Extension name contains underscore, will not generate popularity points.

Similar to templateconfhelper

Tagged with configuration, multitemplate, style, template

This is an extension for the MultiTemplate template to solve the problem with templates using style.ini (discussed here).

Download / Installation

Download the plugin here (manually or via Plugin Manager):

The plugin is compatible with DokuWiki version 2006-11-06 and version 2007-06-26. It requires, that the MultiTemplate template is installed.

For the current version of multitemplate, a small addition in the file /lib/tpl/multitemplate/meat.php is required.

Add the following line to the top of the meat.php file:1)

<?php global $DOKU_TPL,$DOKU_TPLINC; ?>


With this plugin installed, you are now able to use templates making use of style.ini with MultiTemplate . No additional configuration is required.

Remark: if you want to use the default-template, copy the folder /lib/tpl/default/images/ to /lib/tpl/multitemplate/images/ to assure
that the little icons on the bottom work properly.


The plugin consist of two files:


 * Multitemplate Styleman Action Plugin:   Hooks into stylesheet generation to allow
 * templates managed by the mutlitemplate template (
 * the usage of style.ini
 * @author     Pascal Bihler <>
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
class action_plugin_multitemplate_styleman extends DokuWiki_Action_Plugin {
   * return some info
  function getInfo(){
    return array(
		 'author' => 'Pascal Bihler',
		 'email'  => '',
		 'date'   => '2009-02-02',
		 'name'   => 'Multitemplate Stylemananager',
		 'desc'   => 'Allows templates managed by Multitemplate to use style.ini',
		 'url'    => '',
   * Register its handlers with the DokuWiki's event controller
  function register(Doku_Event_Handler $controller) {
       if ($this->isMultitemplateTemplateActive())
    	 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE',  $this, '_replacecss');
   * Relocates the CSS-loading to own method
  function _replacecss(&$event, $param) {
	  global $ID,$conf;
        global $DOKU_TPL;
        $template = NULL;
        // get current template from mutitemplate template:
        // a modification to the current (2007-01-02) version of multitemplate/meat.php is required:
        // Add the following line to the beginning of the file: "global $DOKU_TPL,$DOKU_TPLINC;"
        if (preg_match('/\/([^\/]+)\/$/',$DOKU_TPL,$matches))
          $template = $matches[1];
        if (isset($template)) {
           // Replace stylsheet requests
           for ($i = 0; $i < count($event->data['link']); $i++) {
               if (isset($event->data['link'][$i]['media'])) {
                   $media = $event->data['link'][$i]['media'];
                   // redirect to our css.php-wrapper
                   $href = $event->data['link'][$i]['href'];
                   $pos = strpos($href,'css.php');
                   if ($pos !== false) {
                       $params = substr($href,$pos+7);
                       $params = str_replace( 't=multitemplate', '', $params );
                       if (! $params) 
                       	  $href = DOKU_BASE.'lib/plugins/multitemplate_styleman/css.php?tpl=' . $template;
                       	  $href = DOKU_BASE.'lib/plugins/multitemplate_styleman/css.php' . $params . '&tpl=' . $template;
                       $event->data['link'][$i]['href'] = $href;
   function isMultitemplateTemplateActive() {
	     global $conf;
       return ($conf['template'] == 'multitemplate');


 * DokuWiki StyleSheet creator wrapper
 * @license    GPL 2 (
 * @author     Pascal Bihler <>
 //Load all the basic includes (like css.php tries to do later)
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching)
$template = NULL;
if (isset($_REQUEST['tpl'])) {
    $tpl = $_REQUEST['tpl'];
    if (preg_match('/^[a-z0-9_-]+$/iD', $tpl)) { //seems to be a valid template name, and not a code injection...
        $template = $tpl;
// We set the template constants before init.php can do it...
if (isset($template)) {
   //Inherit DOKU_BASE from server variables in order to avoid config reading here...
   $script_name = $_SERVER['SCRIPT_NAME'];
   $DOKU_BASE = substr($script_name,0,strlen($script_name)-strlen('lib/plugins/multitemplate_styleman/css.php'));
   define('DOKU_TPL', $DOKU_BASE.'lib/tpl/'  . $template .'/');
   define('DOKU_TPLINC',realpath(dirname(__FILE__).'/../../') . '/tpl/' . $template .'/');
//Load environment parameters
// Redirect template: 
if (isset($template))
   $conf['template'] = $template;
//Now we let the original css.php do the rest


Just a minor note. I think it would be better just to replace the style links in the action.php rather then unsetting > the whole array. This way you loose the alternate/contents/opensearch meta links. — Michael Klier 2007-05-22 15:09

Good point, I adapted the plugin accordingly. — Pascal 2007-06-22 13:38

Great work, thank you so much! —Pekka 2008-03-14 15:33
Hello, for me this did not work as long as t was set in the css call as lib/exe/css.php does not use DOKU_TPL.
$params = str_replace( 't=multitemplate', '', $params ); 

fixed this. — sf 2008-10-11 12:05

The same for me, and I could not have done it without SF's help who gave me this essential precision:


              $params = substr($href,$pos+7);


 		$params = str_replace( 't=multitemplate', '', $params );

I suggest that this should be implemented in the next plugin release… — NewMorning 2008/12/21 16:49

done — Pascal 2009-02-02 14:01
You know this game, if you have already tried to adapt existing templates for the use with MultiTemplate
plugin/multitemplate_styleman.txt · Last modified: 2013-11-02 02:22 by Klap-in

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