Template:Namespaced category overriding: Difference between revisions
Fix switch |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{Namespaced category|{{{1|}}}|namespace={{#switch:{{{2|}}}|-1 = -1|1 = {{NAMESPACENUMBER}}|{{{namespace|}}}}}<noinclude>{{Documentation}} | {{Namespaced category|{{{1|}}}|namespace={{#switch:{{{2|}}}|-1 = -1|1 = {{NAMESPACENUMBER}}|{{{namespace|0}}}}}}}<noinclude>{{Documentation}}</noinclude> | ||
Latest revision as of 13:52, 29 January 2022
This template allows for conditional categorisation, where a page will only be placed into a category if the template is used in a given namespace. It is based on {{Namespaced category}}. In addition, it also adds a conditional override system through its second unnamed parameter. If it is sent -1, categorisation is completely disabled (by setting namespace to -1, an impossible combination). If it is sent 1, it always categorises regardless of namespace (by setting namespace to {{NAMESPACENUMBER}}, so the check succeeds no matter what). If set to any other option, including left blank, it performs the namespace check of its dependent template. It is intended for use by integration into other templates, to allow use in applications where automatic categorisation is not always desired (for example, to illustrate usage, or to use the template with parameters that might break automatic categorisation).
Example usage[edit source]
- To categorise pages into Category:Buses, only in mainspace, and pass in a parameter named "force_cat" that can be set to -1 to fully disable or 1 to force:
{{NsCatO|Buses|{{{force_cat|}}}}}
- To categorise pages into Category:Western Digital Marvell families, only in the category namespace, and pass in a parameter named "force_cat" that can be set to -1 to fully disable or 1 to force it to regardless of namespace:
{{NsCatO|Western Digital Marvell families|{{{force_cat|}}}|namespace = 14}}
TemplateData[edit source]
Checks the namespace of the page, and if it matches mainspace (or the number of the given namespace), adds a category. It also adds an overriding function, where 1 forces categorisation and -1 disables it.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Category name | 1 | The name of the category to add if the check succeeds (do not add Category: prefix)
| String | required |
| Force category option parameter | 2 | For use inside templates. The parameter that your template uses to specify category forcing.
| Number | suggested |
| Namespace number | namespace | The namespace number to display this category in.
| Number | optional |