Template:Cat

Cat is used for placing a page in sub-categories of the hub's master category, and also to link to categories relative to the hub. Absolute paths are enabled as well.

Contents

Usage

To place a page in a category, use the following syntax:

{{Cat|Location|Optional Sort Key}}

Replace Location with the location of the category, relative to the hub. Replace Optional Sort Key with a Sort Key to be used in sorting the page into the Category, but only if you're not satisfied with the default.

To link to a category, place a colon before the location, like this

{{Cat|:Location|Optional Alternate Text}}

Replace Location with the location of the category, relative to the hub. Replace Optional Alternate Text with what you would like the link to be named, but only do it if you're not satisfied with the default text.

Notes

  • To specify an absolute path, place a forward slash before the location (after the colon if it's a link).
  • When you define an absolute path, the sort key (or link text) will be absolute as well.
  • To link to a sub-category of the hub's master category, use the same syntax as if you were linking from another sub-page of the hub.
  • To link to the hub's master category, use {{Cat|:/}}. From an image not belonging to a hub, this will link to Category:Main.
  • If you specify alternate text on a link to a category, it only affects how the link appears, not where the link actually goes.
  • Template:Auto has a feature that allows you to place a page in up to 10 categories using the Cat parameter. This feature is a good substitute for using Cat by itself, especially since it calls Cat directly.

Examples of Usage

These examples pertain to placing a page in a category.

Current Page Template Syntax Assigned Category Sort Key (Default) Path Type
Any hub page {{Cat|Mirror's Edge Series}} Category:Mirror's Edge Series Page name Absolute
Mirror's Edge/Melee Combat {{Cat|Game Play}} Category:Mirror's Edge/Game Play Melee Combat Relative
Mirror's Edge/Kate Connors {{Cat|/Mirror's Edge/Characters}} Category:Mirror's Edge/Characters Mirror's Edge/Kate Connors Absolute

These examples pertain to linking to a category.

Current Page Template Syntax Link Location Link Text (Default) Path Type
Mirror's Edge {{Cat|:Characters}} Category:Mirror's Edge/Characters Category:Characters Relative
Mirror's Edge/Faith Connors {{Cat|:Characters}} Category:Mirror's Edge/Characters Category:Characters Relative
Mirror's Edge/Stash Points {{Cat|:/}} Category:Mirror's Edge Category:Mirror's Edge Relative
Doesn't matter {{Cat|:/Main}} Category:Main Category:Main Absolute
Doesn't matter {{Cat|:/Mirror's Edge/Game Play}} Category:Mirror's Edge/Game Play Category:Mirror's Edge/Game Play Absolute

Uncompressed Code

{{#if: {{{1|}}} |
  {{#ifeq: {{#pos: {{{1}}} | :}} | 0 |
    {{#ifeq: {{#pos: {{{1}}} | /}} | 1 |
      {{#ifeq: {{{1}}} | :/ |
        {{#switch: {{PageType}}
        | Sub Page
        | Sub Image
        | Base Page = [[:Category:{{HubName}}|{{{2|Category:{{HubName}}}}}]] <!--({{PAGESINCAT:{{HubName}}}})-->
        | Base Image = [[:Category:Main|{{{2|Category:Main}}}]]
        }} |
        [[:Category:{{#sub: {{{1}}} | 2}}|{{{2|Category:{{#sub: {{{1}}} | 2}}}}}]] <!--({{PAGESINCAT:{{#sub: {{{1}}} | 2}}}})-->
      }} |
      {{#switch: {{PageType}}
      | Sub Page
      | Sub Image
      | Base Page =
        [[:Category:{{HubName}}/{{#sub: {{{1}}} | 1}}|{{{2|Category:{{#sub: {{{1}}} | 1}}}}}]] <!--({{PAGESINCAT:{{HubName}}/{{#sub: {{{1}}} | 1}}}})-->
      | Base Image =
        [[:Category:{{#sub: {{{1}}} | 1}}|{{{2|Category:{{#sub: {{{1}}} | 1}}}}}]] <!--({{PAGESINCAT:{{#sub: {{{1}}} | 1}}}})-->
      }}
    }} |
    {{#ifeq: {{#pos: {{{1}}} | /}} | 0 |
      [[Category: {{#sub: {{{1}}} | 1}}|{{{2|{{FullPageName}}}}}]] |
      {{#switch: {{PageType}}
      | Sub Page = [[Category:{{HubName}}/{{{1}}}|{{{2|{{PageName|Sub}}}}}]]
      | Sub Image = [[Category:{{HubName}}/{{{1}}}|{{{2|Image:{{ImageName}}}}}]]
      | Base Page = [[Category:{{{1}}}|{{{2|{{PageName}}}}}]]
      | Base Image = [[Category:{{{1}}}|{{{2|Image:{{ImageName}}}}}]]
      }}
    }}
  }}
}}