Help:Templates: Difference between revisions

Jump to navigation Jump to search
Unnamed parameters have to be used in specified order + Category suppression
(→‎External links: Some more advanced editing links)
(Unnamed parameters have to be used in specified order + Category suppression)
Line 40: Line 40:


In most cases it is possible to use any kind of wiki markup in the parameters, for example wiki links.
In most cases it is possible to use any kind of wiki markup in the parameters, for example wiki links.
One thing to mention here is that unnamed parameters must be used in a certain order, though they can if not mandatory be left empty.  Take for example the following template:
<nowiki>{{</nowiki>'''template'''<nowiki>|</nowiki>''parameter 1''<nowiki>|</nowiki>''parameter 2''<nowiki>|</nowiki>''parameter 3''<nowiki>|</nowiki>''parameter 4''<nowiki>|</nowiki><nowiki>}}</nowiki>
If we would be to use only the last two parameters we would have to to like this below:
<nowiki>{{template|||parameter 3|parameter 4}}</nowiki>


=== Template documentation ===
=== Template documentation ===
Line 135: Line 141:


[[Category:Hello templates]]
[[Category:Hello templates]]
</noinclude></nowiki>
=== Category suppression ===
Sometimes it is helpful if a template suppresses categorisation and only categorizes some of the pages it is put on.  There is a few templates that can be used for that in [[:Category:Namespace templates]].  Most of them uses the namespace of the page the template is put on. For example '''''Help talk:'''Templates'' is in the ''Help talk'' namespace.
One of those templates is {{tl|main other}}:
<nowiki>{{</nowiki>'''main other'''<nowiki>|</nowiki>''text if main''<nowiki>|</nowiki>''text if other'' <nowiki>|</nowiki>''demospace=''<nowiki>}}</nowiki>
If the template is put on a page in the main namespace, the the namespace that articles are in, the ''text if main'' text is used.  Otherwise ''text if other'' is used.  Both can be overridden if ''demospace='' is set as ''other'' when in the main namespace and ''main'' when in any other.
If a category link is used in ''text if main'' like below the page will only be categorized if the template is put in the main namespace. Note that all the parameters are optional.
<nowiki>
...
}}
{{main other|[[Category:Hello templates]]}}
</noinclude></nowiki>
</noinclude></nowiki>


Navigation menu