Extension:Page Forms/Page Forms and templates/cs

, je ve své podstatě systém pro editaci parametrů šablon, prostřednictvím wiki stránek. (Lze ale také jeho prostřednictvím upravovat sekce stránky.) Více se o roli šablon v MediaWiki dozvíte na stránce.

Zajímá vás, proč lze pomocí upravit hodnoty parametrů použité šablony nebo vybranou sekci stránky, ale ne její kategorizaci? Je to proto, že vychází z toho, že by veškerá data MediaWiki - včetně obsahu, informací o kategoriích, atp. - měly být na stránce uloženy jako hodnoty parametrů v šabloně. A to z několika důvodů:


 * u šablony je dané, kam co patří, což zabraňuje tomu, aby došlo k vytvoření nejednoznačné datové struktury
 * šablona při zobrazení skryje složitou syntaxi, což usnadňuje práci s obsahem, neboť se můžete soustředit pouze na editaci dat
 * šablony umožňují snazší realizaci změn, protože je lze dělat pro všechny stránky na jednom místě, aniž by bylo nutné upravovat jednu stránku po druhé.

poskytuje řadu funkcí, které pomáhají právě při vytváření a zobrazování šablon a nijak nesouvisí s editací formuláře. A ty jsou popsány na této stránce. There is no technical reason why these features are all defined in ; theoretically  and   could be added to the  extension, or perhaps all of the features should go into a new extension. There is certainly an argument of convenience for keeping them in. In any case, there are no current plans to move these.

Simplifying the template display
defines two parser functions,  and , which together can considerably simplify the code needed to display a template call - and can also simplify the definition of any forms that make use of such a template.

Funkce  by měla být v rámci šablony uzavřena v elementu. Obsahuje totiž očekávané parametry této šablony, spolu s dalšími podrobnostmi o každém z nich. Toto je ukázkový příklad volání této funkce u šablony nazvané "Recipe": Povolené údaje (které můžeme označit jako "parametry parametrů") jsou:


 * - text, který se použije k popisu formulářového pole pro tento parametr na stránkách a ve formulářích. Pokud není nastaven žádný popisek, použije se místo něj název parametru.
 * - je-li hodnota nastavena na, zobrazí se jen pokud bude obsahovat nějakou hodnotu.
 * - určuje, že v rámci tohoto parametru může být celá série volání jedné a téže šablony.
 * - pokud je nainstalováno rozšíření, určuje tohle pole v tabulce šablony , kterému z nich bude tento parametr odpovídat. Pokud tento parametr nebude nastaven, vyhledá se pole které svým názvem odpovídá tomuto parametru.

Přidání funkce  do šablony pomáhá následujícími způsoby:


 * Funkce zajistí, přehledné umístění parametrů na stránce šablony.
 * Její atributy usnadní zobrazování šablony (viz následující část).
 * Some of this information is also used by forms, enabling the form definition to be simpler.

The  function should be placed within a template's   tag. It handles the display for a template call. In many cases, provided  has been called, the   can be quite simple. For a template with the above  call, for instance, the   call could simply look like: If, on the other hand, there is no  call, then the   call would have to look like: This is not recommended, though.

There is one pre-defined parameter that  can take:


 * - specifies what format the display should be in; options are  (the default), ,   and  .  displays an infobox on the right-hand side of the page, in the manner of Wikipedia;   displays a table that covers the whole page;   makes each parameter name a section header, with the value below it; and   displays all the template data as text, with the parameter names bolded.

To display all the data as a full-page table, you would simply have to call:

Multiple values for the same field
also defines the parser functions  and , which provide support for having multiple values for a single field, delimited by a comma or other character. These parser functions "map" some text processing onto each value. This can be as simple as turning each value into a link, although there can be more complex processing, like turning each value into a category tag, an image tag, a Semantic MediaWiki property tag, and so on.

and  can also be used outside of a template context, although this page does not really cover that usage.

The generic call for this function is:

The function splits the 'value' by the 'delimiter', and then, for each one, applies the same mapping that 'formula' does to 'variable', and then joins all the values again using the 'new_delimiter' - except for the final value, which is joined by 'conjunction' if it set.

For example: if you have a form that populates the field, and you want the values for that field to be separated by commas and each be a link, you could put the following in the template:

Essentially this function 'maps' the link syntax onto each comma-delimited value in the field. (The 'delimiter' parameter defaults to  and 'new_delimiter' defaults to   (note the extra space) if they are not set.) The user can thus enter all the values on the same line, with or without spaces around the commas. (Note, by the way, that the  is used here as an internal variable; any other string could be used as well, like  .)

The 'new_delimiter' parameter is especially helpful if none of the resulting values are actually displayed, because by default such a thing would show up as a string of commas. A common example of that is if the original value holds a list of category names, and each name gets turned into a category tag, but is not actually displayed.

To avoid displaying commas in that case, you should set the 'new_delimiter' value equal to a space. Using just  at the end won't work, because the MediaWiki parser will ignore it - instead, the easiest approach is to use , which gets translated into a space. Here is how such a thing could be called:

You can make the output look more like natural language by including a 'conjunction' value for the final delimiter, so that the output will look like, for example,  instead of just. Here is an example of how to do that:

If you use the 'CreateTemplate' or 'CreateClass' pages to create a template, and you specify that a field that can take more than one value, then an  call will be automatically added to the generated template.

There are some kinds of mapping that are complex enough that they cannot be placed in the  function. For this purpose, you can instead use the similar  function.

To use this function, first create a template that takes in a single field (it should be referred to in the template as ) and applies the mapping you would like to that field. Then apply  onto the main template field just as you would with , using the following format:

...where 'template' is the name of the mapping template in question.

For example: to display a (comma-separated) list of authors as a numbered list, you could first create a template called "Numbered author", with the following contents:

...then call the following:

Using and   in the delimiter
For both  and , the string   in the value of either 'delimiter' or 'new_delimiter' will get converted into a space, while the string   in either parameter will get converted into a newline.

It should be noted that, if you want an actual line break to appear between values, you should have two newlines (i.e, ) as the delimiter, since MediaWiki requires two newlines in order to display a line break.

Template-based special pages
defines three special pages that relate to templates:


 * Special:Templates, which lists all the templates in the wiki,
 * Special:CreateTemplate, and
 * Special:CreateClass.

Both of the latter two pages (i.e., Special:CreateTemplate and Special:CreateClass) can be used to generate templates automatically.