Template:Ctg

From WIDEVERSE Wiki
Jump to navigation Jump to search
Shortcut:

Adds every category listed in the unnamed parameters to the page it is used on. This handler also includes built in sorting mechanics:

  • Pages that match the category name exactly will be sorted as [[Category:<category>| ]], placing them at the front of the category.
    • This rule also applies to titles that are simple plurals of each other; e.g. Rune and Runes
  • Pages that begin with the category will be sorted with the beginning removed.

This template is not a tool that should be used directly on pages, as it is more efficient for the page itself to use standard categorisation. The main purpose of this tool is to provide categorisation rules for navboxes to mass categorise and sort pages.

Usage
{{Ctg|Category 1|Category 2|...}}
Example
{{Ctg|Rune|Mining}}

Placed on most pages, this would produce

[[Category:Rune]][[Category:Mining]].

On the page Mining, however, it would produce

[[Category:Rune]][[Category:Mining| ]].

On Rune pickaxe, it would produce

[[Category:Rune|Pickaxe]][[Category:Mining]]

Modifiers

These are modifiers that can be used (in any order and amount) by appending them after the category name.

Important notes for all modifiers
Several characters cannot be used in the text patterns:
  1. Percent signs (%)
  2. Colons (:)
  3. Brackets ([ and ])
All matches are case insensitive
e.g.; "rune" will match for all of "RunE", "RUNeSSS", and "ERUNE"

::ifmatches

The ::ifmatches modifier will tell the module to only add the specific category if all or part of the pagename matches the category name.

For example, {{ctg|Rune::ifmatches}} would add Category:Rune to Rune battleaxe or Off-hand rune battleaxe, but not to Adamant battleaxe.

::ifmatches[text]

The ::ifmatches[text] modifier will tell the module to only add the specific category if all or part of the pagename matches the text passed.

For example, {{ctg|Rune::ifmatches[battleaxe]}} would add Category:Rune to Rune battleaxe or Adamant battleaxe, but not to Rune scimitar.

With ::ifmatches, multiple match rules can be defined with multiple sets of brackets. For example, ::ifmatches[rune][whip] will match any page that has either "rune" or "whip" in the title. In the rare cases where it may be necessary to have more than a few matches, they can be formatted with spaces and newlines. For example, the code below is acceptable:

{{ctg|Food::ifmatches[shark] [tuna]
[apple] [orange]
[burnt] [raw] [cooked]
}}
::remove[text]

The ::remove[text] will tell the module to remove the text argument from the beginning of pagenames to use as their sort key. If this function is not specified, then the category's name exactly will be used. Likewise, defining this function will not remove the category name from pages for sorting; however, it will still sort exact matches to the front.

For example, {{ctg|Burnt food::remove[burnt]}} would add Category:Burnt food to Burnt shark as [[Category:Burnt food|Shark]].

If a pagename matches the text to remove exactly, then it will be sorted to the front.

The remove function can be suppressed by using a junk character (such as $). So {{ctg|Rune::remove[$]}} will not have a sort key when adding the category to Rune battleaxe. This will not suppress the front sort for exact title matches; e.g., the previous code will still add [[Category:Rune| ]] to the page Rune.