[dokuwiki] inconsistent usage of DOKU_TPL / DOKU_TPLINC

  • From: Roland Hager <roland.hager@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 17 Sep 2010 10:34:48 +0200

Hi List,

In short: I tried to configure individual template-dirs in an wikifarm environment - and failed.

The whole story:

We have a wikifarm with a central installation which points to separate conf- and data-dirs per instance via the preload.php. That works fine. Now we'd like to give our users the possibility to use their own templates without having to install each of them by ourselves. The first thought was: Hey look for a TPL-Dir Constant as with the DOKU_INC stuff we are already using to point to separate dirs as well. => Bingo! There is DOKU_TPL and DOKU_TPLINC which seems to be just the right thing to adjust.

But it turns out not to work properbly. I added an include in the "inc/init.php" right after reading-in the conf-array where I adjust the two Constants concerning the actual Servername and the choosen template if the custom tpl-dir exists else wise the default tpl-dir ist used. But the output of the wiki was incomplete in both points, the style and the components (like menus).

Searching a little bit around I found two points which do not respect the Constants DOKU_TPL and DOKU_TPLINC:
(referring to stable version "lemming")

1. "inc/template.php" line 17 to 26
=> function template($tpl)
The tpl-dir is constructed hardcoded with the Doku_INC Constant and the default tpl-dir.

Shouldn't it be something like this?

if( @is_readable(DOKU_TPLINC) ){
    return DOKU_TPLINC;

return DOKU_INC.'lib/tpl/default/'.$tpl;

2. "inc/css.php" line 41 to 48
=> function css_out()
The tpl-dir is also hardcoded to use DOKU_INC and the default dir if the GET-Parameter "t" is set with the templates name. If "t" is not set the DOKU_TPL* Constants are used. Okay but GET-Parameter "t" seems to be always set (see: inc/template.php line 338 to 344).

I don't know if it is important at any point to be able to use a different template here as set in the DOKU_TPL* Constants but to me its seems not necessary. Maybe the parameter "t" should just not be set in tpl_metaheaders() of template.php? What would be the best / safest way?

Okay - I fixed this for me and now the output is correct - BUT - I cannot choose the templates on the admin/configuration site. The templates shown here are just these from the default dir. This was the point where I decided to contact YOU to ask:

Is there a chance to safely set an individual templatedir without refactoring the whole project?
Are there more places where the default tpl-dir is used instead of the DOKU_TPL* Constants?

Thanks in advance,
Roland Hager

Other related posts: