Template:Namespaced category overriding/doc: Difference between revisions

From Australian Enthusiasts Wiki
Add shortcut
Add the documentation subpage template
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Template shortcut|NsCatO}}
{{Template shortcut|NsCatO}}
{{Documentation subpage}}
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 {{tlx|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 <code><nowiki>namespace</nowiki></code> to -1, an impossible combination). If it is sent 1, it always categorises regardless of namespace (by setting <code><nowiki>namespace</nowiki></code> to <code><nowiki>{{NAMESPACENUMBER}}</nowiki></code>, 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).
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 {{tlx|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 <code><nowiki>namespace</nowiki></code> to -1, an impossible combination). If it is sent 1, it always categorises regardless of namespace (by setting <code><nowiki>namespace</nowiki></code> to <code><nowiki>{{NAMESPACENUMBER}}</nowiki></code>, 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).


Line 5: Line 6:
*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:
*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:
**{{tlx|NsCatO|2 = Buses|3 = <nowiki>{{{force_cat|}}}</nowiki>}}
**{{tlx|NsCatO|2 = Buses|3 = <nowiki>{{{force_cat|}}}</nowiki>}}
*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:
*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:
**{{tlx|NsCatO|2 = Western Digital Marvell families|3 = <nowiki>{{{force_cat|}}}</nowiki>|4 = namespace = 14}}
**{{tlx|NsCatO|2 = Western Digital Marvell families|3 = <nowiki>{{{force_cat|}}}</nowiki>|4 = namespace = 14}}



Latest revision as of 01:20, 9 December 2022

Icon This is a documentation subpage for Template:Namespaced category overriding.

It contains usage information, categories and other content that is not part of the original template page.

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.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Category name1

The name of the category to add if the check succeeds (do not add Category: prefix)

Example
Buses with unknown VIN
Stringrequired
Force category option parameter2

For use inside templates. The parameter that your template uses to specify category forcing.

Example
{{{force_cat|}}}
Numbersuggested
Namespace numbernamespace

The namespace number to display this category in.

Default
0
Example
2
Numberoptional
Cookies help us deliver our services. By using our services, you agree to our use of cookies.