DEFAULTSORT - Categories and Templates

Categories and Templates

A template can be used to add pages to a category, usually by placing the category link inside tags on the template (e.g. ]). When the template is transcluded into the page, the category link becomes active, and the page is added to the category page. This is useful for categories that have high turnover or many pages included, like cleanup categories.

Changes to the template, however, may not be reflected immediately on the category page. When you edit an article to add a category tag directly, the list of category members is updated immediately when the page is saved. When a category link is contained in a template, however, this does not happen immediately: instead, whenever a template is edited, all the pages that transclude it are put into the job queue to be recached during periods of low server load. This means that, in busy periods, it may take hours or even days before individual pages are recached and they start to appear in the category list. Performing a null edit to a page will allow it to jump the queue and be immediately recached.

To add the template itself to the category page as well, omit the "includeonly" tags. To add the template to a category without categorizing pages on which the template is transcluded, place the category declaration between ... tags.

Parser functions can be used to make the transcluded categories, or the sort key used in them, dependent on other variables, notably PAGENAME.

Passing a category by parameter
] or {{{cat|]}}}
If the user provides a parameter 'cat=XXX' the page will be categorized at the page ], otherwise it will be categorized at the page ]. Calling the template with "cat=" (equal to nothing) disables putting the page in any category.
Excluding non-article pages
{{#if:{{NAMESPACE}} | | ]}}
the variable NAMESPACE is null for mainspace articles. For any space other than mainspace, this ParserFunction will produce an empty string, but for regular articles this will include the article in Category:XXX.

On Wikipedia it is not recommended that templates be used to populate ordinary content categories of articles. See Categorization using templates in the categorization guideline.

Read more about this topic:  DEFAULTSORT

Famous quotes containing the word categories:

    all the categories which we employ to describe conscious mental acts, such as ideas, purposes, resolutions, and so on, can be applied to ... these latent states.
    Sigmund Freud (1856–1939)