Help:Categories

From Festipedia, hosted by the FR Heritage Group

Categories are linked at the bottom of a page. They provide a useful way of grouping related pages. For example, a category called "Locomotives" could include all pages referring to locomotives.

Each page can be put into one or more categories. One category has the strength of simplicity, but by putting it in several categories, you can offer overviews of several contexts in which the subject belongs. One particular locomotive could, for example, belong to one category "Internal Combustion Locomotives", another "Hunslet" (grouping all locomotives built by that maker), a third "WHR(C) Locomotives" and a fourth "Departmental locomotives".

Categories can also be grouped within other categories to form a 'tree'. For example, the article for the locomotive above may not be directly grouped in the category "locomotives". Instead, it can be grouped with other pages and files about the same locomotive into a category for that engine. Then that subcategory (or article, as the case may be) can be included in the categories mentioned above. They, in turn, can then be included in bigger categories – like "Hunslet" in "Locomotive builders", "WHR(C) Locomotives" in "Locomotives", "Departmental locomotives" in "Departmental vehicles" – and so on.

One special use is making incomplete articles (stubs) visible in a category of their own by typing the template {{stub}} at the head of the page.

In this wiki, the category "Top" is the ultimate category, the 'trunk of the tree', from which all other categories (and through those, all articles and images) in the main namespace should be accessible.

Creating categories

To create a category, simply create a page in the Category namespace, e.g. Category:Locomotives. The page should contain a short description of the category, e.g. "Locomotives which have worked on the FR or WHR". This should usually be one or two sentences or, at most, a short paragraph. If the subject warrants a longer article, that should go in the main namespace.

You don't have to create a category page before adding pages to the category. When you create the page, you will be shown the list of pages already in the category. Special:Wantedcategories lists categories which have been used but do not yet have a category page.

Viewing categories

When you view a category page, you will see:

  • The text of that page
  • A list of all the category's sub-categories, i.e. categories which are included in this category. Clicking on the + to the left of the category name will show the sub-categories of that category. This feature uses Javascript and therefore may not work on some browsers
  • A list of pages in the category. This does not include pages in any sub-categories unless the page is specifically also included in this category
  • Thumbnails of the images in this category with the first 20 characters of the image name (unless the category page text includes the "__NOGALLERY__" magic word, in which case the images are included in the list of pages and no thumbnails are displayed)

The items on these lists all link to the relevant pages in the wiki. Up to 200 items will be displayed, with links allowing you to see the rest of the items in the category.

Adding a page to a category

To add a page to a category, simply add a link to the category page, e.g.:

[[Category:Category name]]

Category links are automatically listed at the foot of every page with links to the category pages. They do not appear at the location where the link was inserted. However, these links should always be added to the end of the article text.

If you want to include a link to a category page without adding the article to the category, put a colon after the opening brackets, e.g.:

[[:Category:Category name]]

Specifying sort keys

The pages and images on the category page are sorted according to their page name. The order is based on normal ASCII sort order:

&'(),-./0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZ_
abcdefghijklmnopqrstuvwxyz

This means that Z comes before any lower case character. Spaces in the page title are treated as underscores, so come after the capital letters but before the lower case letters. However, the end of a name always comes before any other character, so Locomotive comes before Locomotive No. 5.

Note that the page name includes the namespace, so all articles in the Help namespace will be grouped together under H unless sort keys are specified.

You can specify a sort key to alter the position of a particular page or image within the lists on the category page. You do this in the category tag that adds an item to a category:

[[Category:Category name|sort key]]

For example, to add James Spooner to a category called People and have the article sorted by "Spooner, James", you would put [[People|Spooner, James]] in the article. The name of the article on the category page does not change - it will still be shown as James Spooner but will be listed under S. The only way of viewing the sort key of an article is to look at the article's edit page.

An article can, of course, use different sort keys for different categories if that is appropriate.

Note that, unlike spaces in page names, spaces in sort keys are not treated as underscores.

If an article is included in a category more than once, only the sort key specified in the last tag for that category will be used.

You can specify a default sort key for a page to be used for any category where no sort key is specified. You do this using the parser function DEFAULTSORT as follows:

{{DEFAULTSORT:''sort key''}}

For esample, specifying {{DEFAULTSORT:Spooner, James}} on the James Spooner page would sort it as "Spooner, James" in any category for which no sort key is specified in the category tag. If DEFAULTSORT is used several times on a page, only the last default sort key specified will be used.

It helps users of the wiki if pages in a category are sorted consistently. It can be useful to specify the system used in the text of the category page.

Hiding categories

When the magic word __HIDDENCAT__ is placed on a category page, that category becomes hidden, meaning that it will not be displayed on the pages belonging to that category. On Festipedia, the magic word is not normally used explicitly but is applied through the {{hiddencat}} template. The feature is mostly used to prevent project maintenance categories from showing up to ordinary readers on article pages.

However, hidden categories are displayed (although listed as hidden):

  • on category pages (whether as parent categories or subcategories);
  • at preview during editing;
  • if the user has selected "Show hidden categories" in user preferences.

Hidden categories are automatically added to Category:Hidden categories.

Templates

Templates can be placed in categories like any other page. They can also be used to place other pages in categories. Changing a template automatically updates the pages using that template so that they are always in the correct categories based on the current template. 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 use the template are put into the job queue to be updated. This means that it may take hours or even days before individual pages are updated 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 updated.

If the template tag is in a <includeonly></includeonly> section, it will apply to pages using the template but the template itself will not be placed in that category. Similarly, if the template tag is in a <noinclude></noinclude> section, the template will be in that category but pages using the template will not be placed in that category.

Specifying a fixed sort key in a template for pages using that template is generally not a good idea as it will result in all pages using the template having the same sort key. However, a useful sort key can be specified based on a variable or a parameter.

Subcategories

Adding a category link to a category page makes the category with the link a subcategory of the category specified in the link.

Categories can also be subcategories of each other, so A can be a subcategory of B while B is also a subcategory of A. However, such mutual inclusion is best avoided as the structure becomes difficult for users to understand.

Related changes

Normally, related changes lists recent changes to pages linked in the text of the page. However, for categories, related changes lists recent changes to pages currently in the category and does not show changes to pages linked in the text of the page.

Note that removing a page from a category will not appear on the "related changes" report. This will only show changes to pages that are currently in the category.

Including a category tree on a page

The category tree for a category shows the subcategories and, optionally, pages and images which are members of the category. Each subcategory can also be opened to show its members. This feature uses Javascript so may not work on all browsers.

The category tree for a category can be included in any article using the <categorytree> tag. The syntax is:

<categorytree options>category</categorytree>

This will display the tree for category - this is referred to as the root category. The options specify how the tree is to be displayed. The options are mode, depth, hideroot, onlyroot and style. Each of these is set using the syntax option="value" as for HTML attributes.

For example, <categorytree>Locations</categorytree> gives:

.

mode

The mode can be:

  • category - display only subcategories
  • page - display subcategories and pages but not images
  • all - display subcategories, pages and images

If mode is not specified or an invalid value is given, it will default to category.

depth

This must be numeric. It specifies how many levels of the tree are shown initially. The default is 1, showing the root category and its members. Setting depth to 0 will display only the root category. This has no effect on the number of levels that can be viewed by the user clicking on the [+] links to the left of each category. Note that, if the mode is category, the maximum depth is 2. For other modes, the maximum depth is 1.

hideroot

If this is set to on, yes, true or 1, the root category will not be displayed. Only the members of the root category will appear. If hideroot is on, setting depth to 0 or turning on onlyroot will have no effect.

onlyroot

If this is set to on, yes, true or 1, only the root category will not be displayed. This is equivalent to setting depth to 0.

style

Any styles to be applied to the tree can be specified.