MindTouch Developer Center > Deki > FAQ > Visual Customization > How do I...Implement global templates?

How do I...Implement global templates?

Table of contents
  1. 1. Known issues

With the addition of template targeting in Deki 8.05.1, it also becomes possible with Deki 8.05.2 to implement global templates - these are pages which are loaded with every page load - any content in these global templates outside the main content area will be injected into the template.

Following up with the template targeting example, let's say we wanted this target to be applied to every page in the system. First, we have to create a normal page which executes the template into the proper area. Let's create a sub-page in our user namespace ("User:Admin/Header") which executes the wiki.template call:

{{wiki.template("Date", nil, "currentdate")}}

Now we have to specify our sub-page ("User:Admin/Header") to be called from every page load.

To do this, load up LocalSettings.php, and modify the $wgPreloadPages array:

$wgPreloadPages = array('User:Admin/Header');

You will also want to add the targeted skin key into LocalSettings.php:

$wgTargetSkinVars[] = 'currentdate';

This is done so malicious users cannot overwrite skinning variables such as the login box.

On every page, you should now see the date successfully injected!

Because $wgPreloadPages is an array, you can specify multiple pages to be loaded by separating the page names with commas - but be careful using this - it is an expensive operation!

Known issues

In Deki 8.05.2, there is a known issue where viewing an older revision of a document will throw the error message strip above - this is because the revision lookup call is being passed onto the global template page (when it should not be). This is strictly a visual defect - it will not affect the operation of your Deki.

Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08.2