====== “Wikimedia Style Templates” Plugin ====== ---- plugin ---- description: Wikimedia-style templates author : Vitalie Ciubotaru email : vitalie@ciubotaru.tokyo type : syntax lastupdate : 2018-07-22 compatible : Greebo, Hogfather, Igor, Jack Jackrum depends : conflicts : similar : include tags : wikimedia,mediawiki,wikipedia,template,command,include downloadurl: https://bitbucket.org/vitalie_ciubotaru/wst/get/HEAD.zip bugtracker : https://bitbucket.org/vitalie_ciubotaru/wst/issues sourcerepo : https://bitbucket.org/vitalie_ciubotaru/wst/ donationurl: screenshot_img : ---- This plugin provides a syntax for [[wp>Help:Template|WikiMedia-style templates]]. ===== Installation ===== Search and install the plugin using the [[plugin:extension|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: //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|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|{{{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 **** and **** tags, as follows: //The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.// 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 **** and **** tags, as follows: Plugin syntax: {{wst>main|Article_name}} //The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.// ==== 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. ====== Documentation: main ====== << [[template:main|Main]] ===== Syntax ===== {{wst>main|Article_name}} ===== Output ===== //Main article for this section is **[[category:article|Article_name]]**.// {{wst>main_doc}} //The main article for this section is **[[:{{{1}}}|{{{1}}}]]**.// ===== 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 ==== * **...** -- the text will be displayed on a page (e.g. a template page), but will not be shown on pages that call the template. * **...** -- 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 ===== === Change Log === * **2017-04-17** * Initial release === Known Bugs and Issues === === ToDo/Wish List === //[developers roadmap]// ===== FAQ ===== * [[~:l10n|Localization]] ===== 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// > It's worth mentioning in the discussion that this isn't always an undesirable feature, for instance when creating inter page link lists etc that would muddle the meaning of a page-link by adding links all over the place. > > Also, you can find the usage of a template with the search engine. It will hit ''"{{wst>..."'' just like any other text on the pages. I also suspect plugins like the PageQuery plugin might be able to do that programmatically. ==== Localization, GitHub, Enhancement ==== I am the current maintainer of [[plugin:templater|Templater]]. WST is everything I wanted. If I had found it earlier, I wouldn't have adopted the Templater. I'm amazed that after 5, almost 6, years it still works without the need for a patch. Yes, tested in **Jack Jackrum** today, right now. Could the developer: - Add this plugin to https://translate.dokuwiki.org for easier translation? If not possible, could developer add my translation to source? Download here [[https://drive.google.com/uc?export=download&id=1fwAZTaahvDF94XjU0sA8UPx1io-P9vm7|pt-br]] (Google Drive). - Move this to GitHub instead of BitBucket? - In ''plugin.info.txt'', is better to change **url** to ''%%https://www.dokuwiki.org/plugin:wst%%'' instead of ''%%https://bitbucket.org/vitalie_ciubotaru/wst%%''. All plugins do this way. --- [[user>nerun|Daniel D. Rodrigues]] //2023-12-08 20:29// ==== ParserFunctions ==== Please, try my [[ParserFunctions]] plugin, it's a perfect companion for WST and [[Templater]]. --- [[user>nerun|Daniel D. Rodrigues]] //2023-12-10 21:13// ==== Conflict between the move plugin and the wiki style template plugin ==== I reported [[https://github.com/michitux/dokuwiki-plugin-move/issues/272|a bug]] when [[plugin:move|the move plugin]] scrambles variable inserts in WST-templates, but reading through the page for the move plugin it seems the WST plugin might need to implement some management for moves and move events. I'm reporting this here because there doesn't seem to be any other place?