It's better when it's simple

User Tools

Site Tools


Multitemplate for DokuWiki

Compatible with DokuWiki


template This template allows you to use any templates you wish for any namespace (or page) you wish.

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.


It's not required, but please consider linking to this page from your site if you like this product.


Before downloading or using this product, make sure you understand and accept the terms of the license.

After downloading, make sure to follow the install instructions or upgrading instructions below; trust me, they're worth reading.

  • Older downloads are available on request only.

Note: always points to the latest stable version!


  1. download the tarball/zip-file
  2. unpack it into <dokuwiki>/lib/tpl/
  3. login as admin and change the template in the configuration manager

using git:

% cd <dokuwiki>/lib/tpl/
% git clone git:// multitemplate

Debian install (or probably any other distribution):

# cd /usr/share/dokuwiki/lib/tpl/
# wget
# tar -xvzf multitemplate-stable.tar.gz
# chown -Rv 33 multitemplate/

Note: always points to the latest stable version!


This template allows you to use multiple templates in one DokuWiki installation, based on what the path to any particular page begins with.

For instance, you can have the monobook template for all of your site, roundbox template for user directories, SXS for discussions, and default for the playground.

Better yet, if you're making a customized site, you can simply make different templates for different sections.

In fact, you can even use custom templates for individual pages; so you could make playground:playground have another custom template that would be different from other pages in the playground namespace.

So there you have it. Now let's see how to configure it.

The $multitemplate Variable

The $multitemplate variable is your way to configure which templates get applied to which pages on your website. All you simply need to do is edit local_pref.php in the multitemplate folder.

Here is the default configuration:

$multitemplate['playground'] = 'default';
$multitemplate[''] = 'monobook';

This makes it so that the “default” template gets applied to the playground namespace, or any path/file that begins with “playground”. Then, anything that doesn't match, by default, gets the “monobook” template.

Just add or remove lines as you see fit. Ok, so simple enough, right?

But there's one thing to consider– lets say that we want to use a different template for a page that is located at “playground:test”.

This will not work:

$multitemplate['playground'] = 'default';
$multitemplate['playground:test'] = 'roundbox';
$multitemplate[''] = 'monobook';

Why is this the case? Because 'playground:test' will match against 'playground' first, and then terminate. So the rule to remember is, longer namespaces go first. That means 'playground:test' comes before 'playground'.

So here's what your local_pref.php would look like:

$multitemplate['playground:test'] = 'roundbox';
$multitemplate['playground'] = 'default';
$multitemplate[''] = 'monobook';

So, is that all the configuration you need to do? No, keep reading!

How to modify your templates

Here is the last part. You must modify your templates first because of the way multitemplate works.

The latest version of monobook for dokuwiki will already work with multitemplate as is.

For some templates, or templates you make yourself, you'll only need to do a few things:

  • Open each .php file in the template and replace DOKU_TPL with $DOKU_TPL
    • If they use DOKU_TPLINC, replace with $DOKU_TPLINC as well
  • Add the following line to the top of each .php file:

And that's it, now it is multitemplate ready. Also, this will allow the template to work stand-alone or with multitemplate.


<note warning> If you require style.ini support, there is also a style.ini helper plugin for Multitemplate by Pascal Bihler that you will need to install. </note>


Installation itself is simple, just unzip the file into the folder lib/tpl in your DokuWiki install, and add $conf['template'] = "multitemplate"; to your local.php file, which is located in the conf folder in your DokuWiki install.

As with monobook for dokuwiki, I suggest you turn offCompress CSS and javascript files” because it's a buggy feature in DokuWiki.

Additional Notes

  • In general, any time you change templates, make sure you do a force-refresh on your website. You can do this in FireFox and Internet Explorer by holding shift-control-alt and clicking the refresh button. This flushes the browser's copy of any cached content (particularly stylesheets) on whatever site you're on, so you'll get the latest copy.

If one or more of your templates use the configuration manager, you will need to open the configuration manager and configure the template for each different template you have.

In other words, if you use the templates “monobook” and “default”, you will need to:

  • Open a page that uses the “monobook” template, click admin, then click configuration settings, and set your preferences for this template.
  • Open a page that uses the “default” template, click admin, then click configuration settings, and set your preferences for this template.1)

You may notice that you'll end up with a section called “Undefined settings”; this is normal though.

What's New


  • Configuration Manager support


  • Media manager support


  • Figured out why “media file selection” didn't work and fixed it.


  • Initial release


  • Start all subtopics using H2. (Heading 2.)

Sites using this template

Link your site here if you wish

Thank you very much for your outstanding work, in my opinion your Monobook for Dokuwiki, and the multi-template plugin are the best additions for Dokuwiki in the world! - You are the Greatest! Thank you!


Better way to integrate style.ini templates?

If someone has a better way to integrate style.ini templates with multitemplate, please reply and the solution will be integrated into the project. — Terence J. Grant 06/24/2006 00:52
I've created an action plugin solving the problem with style.ini: multitemplate_stylemanPascal Bihler 05/15/2007 14:38

Awesome Pascal! I've added a link to this to the main page. — Terence J. Grant 05/17/2007 01:52

Careful with tplSwitcher (Template Switcher)

Don't use this plugin with multitemplate. In my case it caused chaos.


Bug reading template configuration settings

When I'm using the sidebar-template, the configuration settings are important. If there are no configuration settings, the sidebar will not be shown.

Now I noticed that the current version of multitemplate is not able to aquire the configuration settings for sidebar, when it is used in a sub-namespace.

A quick-and-dirty workaround will help:

Modify ./lib/tpl/multitemplate/conf/meat.php, add the following code on top:

// Workaround
if (isset($ID) == FALSE) {
  $ID    = getID();
// /Workaround

It seems, that the $ID-Variable is never set, when this skript will be run.


Multitemplate still broken for monobook?

Hi - I have just spent a few hours trying to get multitemplate working, and have finally found this annoucnement from Dec 20 2006 indicating that it's broken. What is wrong with it, and could you please fix it? Currently I am fairly sure I have installed it correctly, but it seems stylesheets are not being referred to correctly (looks for them in /lib/tpl/multitemplate instead of in /lib/tpl/monobook

Thanks much! Tobias Eigen

Multitemplate is not broken, the fix for January was to do with the configuration manager.

My guess based on your problem is that you haven't turned off “compact CSS and JavaScript files” in the main configuration settings. This is absolutely required.

I've expressed my feelings regarding this buggy (and fairly useless) feature existing in DokuWiki, as well as it being on by default since it causes so many headaches (like caching the wrong CSS files when you change templates.)

Additionally, you'll probably need to do a “force refresh” by holding down the “modifier keys” (that's shift, alt, and control) while hitting the refresh button (with the mouse) on your browser (I'll add a note to the project page for this.)

I'm fairly confident this will fix your problems though. — Terence J. Grant 03/23/2007 22:35

Geez, it's even worse than I thought. Not only is it not broken but I'm a complete idiot. I accidentally uploaded the multitemplate to the wrong location (plugins not tpl) so obviously it was not working. Now it is! Like a charm!! Thanks much! Tobias Eigen

Multitemplate "headers already sent" issue

Hi -

I'm getting the following error message when saving configuration settings in my dokuwiki, with the multitemplate installed. I am suspecting this is related to another problem I am having, which is that I can't get the configuration to be different for each of my templates (I'm using copies of monobook for each namespace, e.g. monobook_web20, monobook_ttgo etc). The different configurations work when I'm not using multitemplate and directly using eg monobook_ttgo but not when I have the multitemplate selected as the template. Otherwise it seems to be using the different templates, as I've got different logos for each and they are showing up.

Warning: Cannot modify header information - headers already sent by (output started at /var/www/foo/wiki/lib/tpl/multitemplate/conf/default.php:11) in /var/www/foo/wiki/lib/plugins/config/admin.php on line 84

Thanks much for any guidance -Tobias Eigen
I found the cause of the “headers already sent” issue .. see here: sessioncookie - but am still struggling to get my configuration files to be different for each template. This is driving me nuts. -Tobias Eigen

If you're using multiple copies of the same template, which is something i really never expected, you'll have to change some things within the template's code…

  1. Search for the function name “tpl_getConf” in all of the php files in the template, and change the parameter name per template…
    • So for instance, if you find tpl_getConf('mb_use_sitenotice'), you'll need to call one 'mb_...', perhaps another 'mb_web20_...' and 'mb_ttgo_...' and so on for each, this differing per template directory.
  2. You'll then need to go to the “conf” directory for each template, and modify both default.php and metadata.php to do the same thing.
  3. You'll then want to do the same thing with “lang/en/settings.php” or whatever your default language is and change that as well.

I believe that should be enough to fix everything for you. — Terence J. Grant 03/27/2007 19:17

You are right, Terence - many thanks! I got part of the way there myself a while after posting this.. see;nocount for details, and below for the record the files that need to be changed. This is a cumbersome process and if ever you find a way to handle this issue in future upgrades it would be massively useful, at least to me. Having distinct navigation, talk and other notices etc is very useful indeed, even when using the same brilliant template for all of them.

1) Added the following to ~conf/local.protected.php for each namespace

$conf['tpl']['multitemplate']['ttgo_use_discussion'] = 1;
$conf['tpl']['multitemplate']['ttgo_discussion_location'] = 'talk';
$conf['tpl']['multitemplate']['ttgo_use_navigation'] = 1;
$conf['tpl']['multitemplate']['ttgo_navigation_location'] = 'navigation_ttgo';
$conf['tpl']['multitemplate']['ttgo_use_sitenotice'] = 1;
$conf['tpl']['multitemplate']['ttgo_sitenotice_location'] = 'sitenotice_ttgo';
$conf['tpl']['multitemplate']['ttgo_use_copyright'] = 1;
$conf['tpl']['multitemplate']['ttgo_copyright_location'] = 'copyright_ttgo';
$conf['tpl']['multitemplate']['ttgo_use_toolbox'] = 1;
$conf['tpl']['multitemplate']['ttgo_use_defaulttoolbox'] = 1;
$conf['tpl']['multitemplate']['ttgo_toolbox_location'] = 'toolbox_ttgo';
$conf['tpl']['multitemplate']['ttgo_author'] = 'Anonymous Contributors';

2) Replaced the code as you suggested where they appear in these three files in the template:

context.php main.php lang/en/settings.php

3) And also updated the default.php and metadata.php files in the template/conf dir. Tobias Eigen

Template not applied

Hi !

I would like to try Multitemplate for DokuWiki but, after the installation's procedure, when I force the refresh of my start-page, I obtain a page with all the content but without any css file applied… I don't understand why.
To give more details, I used only two templates : the default template and a copy of this one, called “mywiki”, with only one change in the layout.css (background-color of the bar changed into red). I assigned the default template to the playground and the “mywiki” template for all the other pages.
Thank you for your help.
PS : Sorry if my english is not so good… I did my best but ask me if something is not clear in my explanation !

EDIT : I found the problem : default template needs style.ini file… So it needs multitemplate_styleman plugin… ;-)

Bug report with latest version

I believe I do have a bug report for multitemplate on rc2008-04-11. *Update: Same problem with 2008-05-05, same way to solve* If this was somehow my template's fault rather than multitemplate's or dokuwiki's, please don't kill me :) I have quite a lot of things to sort out right now and my top priority was to get it fixed as fast as possible.

I had a dokuwiki installation running multitemplate and the assistant plug-in with three different, self-made themes.

When I upgraded to rc2008-04-11, all pages showed up broken, only the naked content appeared with no CSS definitions at all.

I quickly determined this to be because multitemplate_styleman's css.php did *not* output my template's style sheets even though the style.ini file definitely contained them. Long story short, the error turned out to be in /lib/exe/css.php.

around line 44, you find

 $tpl = trim(preg_replace('/[^\w-]+/','',$_REQUEST['t']));
      $tplinc = DOKU_INC.'lib/tpl/'.$tpl.'/';
      $tpldir = DOKU_BASE.'lib/tpl/'.$tpl.'/';
      $tplinc = DOKU_TPLINC;
      $tpldir = DOKU_TPL;

$tpl needed to be false for my templates to work and the DOKU_TPLINC/DOKU_TPL constants become authoritative.

Add the following lines directly below the first line quoted above ($tpl = trim…):

  if ($tpl == "multitemplate")
      $tpl = trim(preg_replace('/[^\w-]+/','',$_REQUEST['tpl']));

Pekka (

Pekka, I applied your patch but it seems not to help in my case. The web developer toolbar still shows CSS errors – inside the multiteplate plugin, I still see __border__ and other strings that should be defined in style.ini. I used &purge=true in the URL as well as the “strong reload”, the errors stay. in tpl/multitemplate/local_pref.php is only one valid line, and this line reads $multitemplate[''] = 'monobook';. I even replaced the style.ini of monobook by the default style.ini and a customized one from ACH template, but to no avail. — Werner 2008-12-01 14:05 CET
solving my own issue… On multitemplate_styleman I found the hint to insert the statement $params = str_replace( 't=multitemplate', '', $params ); in css.php would help – and it did, now __text_neu__ and things like that are gone! There still are warnings, but it's only about attributes unknown to my FireFox 2.0.18 like 'filter', 'white-space' and so on. — Werner 2008-12-01 14:30 CET

Auto-update translated namespaces

I use multitemplate and translations. I did not want to have to update the multitemplate settings for each language, so here is a small extension that automatically applies your $multitemplate settings to every language registered with the translation plugin.

Copy and paste at the very end of multitemplate/local_pref.php, right before the closing “?>”.

/* Automatically adds all languages registered with the translation plugin
   to each and every $multitemplate entry. 
   eg. with the languages Italian, German, and Dutch registered, the $multitemplate entry
   $multitemplate["my_personal_page"] = "personaltemplate"]
   will become
   $multitemplate["my_personal_page"] = "personaltemplate"]
   $multitemplate["it:my_personal_page"] = "personaltemplate"]
   $multitemplate["de:my_personal_page"] = "personaltemplate"]
   $multitemplate["nl:my_personal_page"] = "personaltemplate"]
  @author Pekka Gaiser <>
if (isset($conf['plugin']['translation']['translations']))
// Borrowed parsing routine for the "translations" string from the latest version of the translations plugin
$languages = strtolower(str_replace(',',' ',$conf['plugin']['translation']['translations']));
$languages = array_unique(array_filter(explode(' ',$languages)));
/* Now we have all translation languages in an array.
   Each entry in $multitemplate will now be completed by an entry each language there is. */
// We make a copy of $multitemplate to not confuse the loop
$multitemplate_tempCopy = $multitemplate;
// Go through every $multitemplate entry and there, through every language.
foreach ($multitemplate_tempCopy as $key => $value)
	 foreach ($languages as $language)
	 $multitemplate[$language.":".$key] = $value; 
 } // end foreach
unset ($multitemplate_tempCopy);
} // end if isset

Pekka (

Multitemplate breaks W3C validation of my template

I do appreciate this template that lets me choose between dokuwiki's default here and a more personnal here, builded on a sidebar base. Unfortunatly and for a reason I can't explain, I can easily validate both templates on W3C validator (using the icon at bottom of the page) whatever template I use, but not if multitemplate is choosed in dokuwiki's config. I get the message :

Sorry, I am unable to validate this document because on line 287 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.

The error was: utf8 “\xE9” does not map to Unicode

The stranger part of the story is that W3C validator still validates dokuwiki's default but does not validate my own template, which is only validated when seclected as main template in dokuwiki's configuration. I did check that this was not due to the page's content, validating my own template on the start page too.

What's wrong with my template used by multitemplate ? What can be done to that ?

Unwanted template changes when searching

(I've just posted this on the DokuWiki forum. Then I thought it could be useful to add it here too. Sorry for the duplication; I'll remove this later if needed.)

This is my test config:

$multitemplate['playground:playground'] = 'default';
$multitemplate['foobar'] = 'doogiestpl';
$multitemplate[''] = 'monobook';

I visit the start page (monobook template), and I use the search box in both possible ways, using foobar as search term; the query portion of the URL and the resulting page are as follows:

  • Search: ?do=search&id=foobar&fulltext=Search (shows a results page with link to foobar:start)
  • Go: ?id=foobar (shows the “This topic does not exist yet” page)

So far so good. But… since both include the parameter id=foobar in the URL, the displayed pages use the doogiestpl template, even though I have not visited the foobar namespace yet.

Same problem using as search term id=foobarwhatever, since function mt_beginsWith(), in meat.php, considers this a match. It seems that the matching criteria should be more conservative…

—efege, feb 27 2009

I don't believe the default template has configuration settings, but you get the point, right?
template/multitemplate.txt · Last modified: 2016-01-15 18:22 by Aleksandr