Table of Contents
Wikimedia Style Templates
Compatible with DokuWiki
- 2023-04-04 "Jack Jackrum" unknown
- 2022-07-31 "Igor" yes
- 2020-07-29 "Hogfather" yes
- 2018-04-22 "Greebo" yes
This plugin provides a syntax for WikiMedia-style templates.
Installation
Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.
If you install this plugin manually, make sure it is installed in lib/plugins/wst
. It might not work if the directory is called differently.
Examples/Usage
Let's assume that we need to add the same fragment to many articles, something like “The main article for this section is [link]”. In order to automate this task, we'll create a template that would accept the link destination and generate the desired text with proper formatting.
Let's also assume that the default namespace for our templates is set to “template” (you can check your settings in “Admin→Configuration Settings”).
Minimal example
First, we create a new page called “template:main” with the following contents:
- template:main
//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//
Now go to the desired article and insert the following code:
{{wst>main|Article_name}}
where “Article_name” is the page that your link will point to. After you save it, you will get:
The main article for this section is Article_name.
Includeonly tag
The template in the minimal example works fine, but our “template:main” page looks ugly:
The main article for this section is {{{1}}}.
Let's change the template so that the desired text appears on other pages (where the template code {{wst>main|}} is inserted), but is hidden from the template page itself. We will wrap the code between <includeonly> and </includeonly> tags, as follows:
- template:main
<includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>
Now the template page looks empty, although it contains the template code.
Noinclude tag
Instead of showing the ugly template code (and instead of showing an empty page), let's add some text that would appear on the template page, but not on pages where the code {{wst>main|}} is inserted. We will wrap this text between <noinclude> and </noinclude> tags, as follows:
- template:main
<noinclude>Plugin syntax: {{wst>main|Article_name}}</noinlcude> <includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>
Template complete with documentation
When creating a template, it would be nice to also create a documentation for the users. One way to create documentation is to create another template, say “main_doc” or “main/doc”. The documentation template will only show the template syntax and the resulting text.
- template:main_doc
====== Documentation: main ====== <noinclude><< [[template:main|Main]]</noinclude> ===== Syntax ===== <nowiki>{{wst>main|Article_name}}</nowiki> ===== Output ===== //Main article for this section is **[[category:article|Article_name]]**.//
- template:main
<noinclude>{{wst>main_doc}}</noinclude> <includeonly>//The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.//</includeonly>
Syntax
A basic syntax for templates created with WST plugin is:
{{wst>template_name|argument_1|argument_2}}
where:
- the template code is always wrapped between double curled brackets;
- wst> is common for all templates;
- template_name is the name of a page in wst namespace (default is “template:”);
- argument_1, argument_2 etc. are arguments to the template code separated by a vertical line.
Named and numbered parameters
By default, each argument can be referred by its ordinal number, i.e. {{{1}}} refers to the first argument, {{{2}}} to the second etc. It is possible to explicitly specify the number of the argument:
{{wst>template_name|1 = argument_1|2 = argument_2}}
In this notation, the actual order of arguments does not matter any more.
Besides this, arguments can be referred to by a name. For example, in the following code
{{wst>template_name|a = argument}}
the parameter can be referred to by {{{a}}}.
Tags
- <noinclude>...</noinclude> – the text will be displayed on a page (e.g. a template page), but will not be shown on pages that call the template.
- <includeonly>...</includeonly> – the text will be displayed only on pages that call a template, but not on a template page itself.
Configuration and Settings
The only setting available is “Default namespace for Wikimedia-style templates”, which defaults to “template”. Leaving the default value should be OK for most installations. If this namespace is already used by another template, just provide another value.
Development
[downloadable blocks, development comments]
Change Log
[preferable GitHub RSS feed or similar]
- 2017-04-17
- Initial release
Known Bugs and Issues
[this section might not be needed in case of external bug manager, or use RSS feed]
ToDo/Wish List
[developers roadmap]
FAQ
[discussions should ideally be deleted and turned into FAQ entries along the way]
Discussion
Does this only work for links. What if the user has a paragraph marked for H1 and wants to change it to H2? What would the template look like? Or am I misunderstanding how this works?
This plugin is not supporting backlinks, so there is no way to use dokuwiki backlinks functionality for links in templates. Also because of that there is no way of knowing which pages include template page.
– lopar4ever [at] gmail