Help talk:Categories

Sub-categorising
Should anyone add information here on how to put one category under another (subcategory)?
 * This was done a while back (but since the question was asked) --HappyDog 16:35, 27 August 2007 (UTC)
 * The explanation about how to add subcategories is unclear. I inserted comments directly into the article highlighting the ambiguities. 66.220.233.173 19:33, 27 September 2010 (UTC)

Hiding categories
How does one hide category display?


 * You can hide the category links at the bottom of a page using CSS (e.g. ).  --HappyDog 01:36, 28 June 2007 (UTC)

But how does one hide an article (or something like a template) from being included within a category?

Hiding categories from category pages
I am using MediaWiki 1.15.1 and would like to hide some categories even from category pages, something which is impossible right now, AFAIK. Reason: I use categories as dynamic table of contents and the categories I want to hide are shortcut redirects, then are just maintenance.

Is it possible? Is it in the queue line for implementation? FYI, here's the ticket I started at MediaZilla.

Thanks!

David Latapie 08:59, 15 November 2009 (UTC)

Intro
I think it's important to define what a Category is. It could be placed before the help section where it explains how to add a category, as a noob might not know what the Category does. Just a suggestion. --Hawkwynd 12:23, 24 August 2007 (UTC)


 * Thanks. It's a wiki, so feel free to add this kind of text yourself!  In the meantime, I've added a rough-and-ready intro.  Please tweak it if you feel the need. --HappyDog 16:35, 27 August 2007 (UTC)

second independent category system
I want to introduce a second category system in my wiki or let me call it an "advanced Tag-System". The idea is to tag every page with some words as links - similiar to the categorie syntax. When I then click this words, I want to see a page with the content of "what links here". Besides this I want to keep the standard category tree. Have anyone has an idea, how to realize this? --87.162.127.221 13:43, 14 October 2007 (UTC)
 * Try Semantic MediaWiki? --141.14.26.125 08:21, 19 February 2008 (UTC)

Language
Could someone please add a guide on how one can change the name "Category" into something localised in other languages? --David Munch 14:41, 12 April 2008 (UTC)
 * I would think that would be the "MediaWiki:Categories" page of your wiki; accessible via "Special:Allmessages". --Lance May 12:49, 12 June 2008 (UTC)

Sorting question...
In an interesting display, I have managed to thoroughly confuse myself with categories. When sorting using the "" suggestion, I've gotten my templates to exhibit the appropriate behavior. The category is "Templates", and the namespace is the default "Template". This works perfectly. However, when I tried this with another category (originally the same name in category as in namespace), they simply sort by the namespace. I've since renamed the category and left the namespace the same. It still sorts by the namespace. The only difference in the two situations that I can see now is that the problematic pages are also tied to another category. Do categories not sort if the pages are attached to more than one? --Lance May 18:04, 11 June 2008 (UTC)
 * Okay, so just in case there are others out there who may have a similar issue. Any level of pride does not prohibit me from saying that the issue above was not only my fault, it was my complete ignorance of the product's features. Essentially, I had expected that namespaces would be created just as any other page; through usage. Granted, this would not be feasible in situations like Wikipedia, so I can see why it is not that way. So that is what the delta was between the two situations; one was a real namespace and had a, the other was not and did not. However, in the interest of possibly lending a hand to anyone else running across this issue, please see Manual:$wgExtraNamespaces before just creating "Something:Like_this", as it will not become a namespace without setting it up ahead of time.

in pages categorized via templates
I'm facing a problem to which I haven't yet found any answer or solution: in a wiki I collaborate to, we have a kind of pages that are categorized in two different ways: When I decided for DEFAULTSORT in place of the old procedure of manually inserting a sort key in each category tag (and for the templates, by passing the sort key as parameter), I discovered that DEFAULTSORT only works for the categories local to the page, but not for the ones inserted by the templates. Is there a way to change this behavior and force all categories to follow DEFAULTSORT? Even a tweak in the wiki code would be welcome! Thanks --Capmo 21:49, 12 October 2008 (UTC)
 * 1) via directly receiving category tags (say,  ), and
 * 2) by receiving templates that categorize the page indirectly (i.e.: templates   that insert the page in categories  ).


 * should apply also to categories included via templates. However, keep in mind that it's the default sort key: any explicitly specified sort key will override it.  —Ilmari Karonen 22:58, 14 December 2008 (UTC)


 * Thanks for your reply, you were right: some of the templates had a sortkey code defined in them that was preventing DEFAULTSORT from working properly. It was something like this:  . When no sortkey was passed as parameter, the "magic word" PAGENAME would become active and override DEFAULTSORT. When I removed all that and left only    everything worked fine! Capmo 04:50, 15 December 2008 (UTC)

Changing items listed per category
I know I can place the following global variable into LocalSettings.php

$wgCategoryPagingLimit = 600;

To alter all categories in a Wiki.

But someone said that the latest MediaWiki now allows this to be done on a per category basis?

If so, does anyone know the magic word I add into a category page to do this?

I can't find it listed.

--Stuart Halliday 12:10, 20 January 2009 (UTC)

Sort by more than one character
What if I want to sort by year? If I do it will be listed on the :Category:Year page under "2", right along with articles in I would rather have it be listed under "2009," so that "2008" shows up separately.


 * I had the same desire, with the addition that I wanted it to be controllable. So I wanted to be able to either provide a specific sort or else I wanted one to be automatically found (based on the first character). I searched around, but couldn't find anything that worked for me. What I ended up doing was just modifying the library code (bad; I know.)
 * In ../includes/CategoryPage.php I modified the "addPage" function to be;

/** function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) { global $wgContLang; $titletext = $wgContLang->convert( $title->getPrefixedText ); $this->articles[] = $isRedirect ? ' ' . $this->getSkin->makeKnownLinkObj( $title, $titletext ). ' '		: $this->getSkin->makeSizeLinkObj( $pageLength, $title, $titletext ); if($wgContLang->firstChar( $sortkey )=="("){		$this->articles_start_char[] = $wgContLang->convert( trim($sortkey,"") );	}else{		$this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) );	} }
 * Add a miscellaneous page
 * This change allows a sort key to be wrapped in parentheis, in which case the key is fully displayed in the category list. For example, the following would list the page under a key of "2009" instead of just "2".


 * I'm sure there's a much better way to acheive this same result. Modifying the base library code is never something that should be done and the code above is far from "good" (for example, a key of "(2009 (June))" would result in "2009 (June" instead of "2009 (June)" as would be desired.) But it gets the job done (or does so enough for my needs.) Hopefully someone with more knowledge/experience could offer a more agreeable solution...? --Dlhdesign 00:49, 22 September 2009 (UTC)
 * Here a modified version of the above "if"-statement that let's you sort the articles within the "headlines":

if($wgContLang->firstChar( $sortkey )=="("){			$closepar=strpos($sortkey, ")"); $sortkey=substr($sortkey, 0, $closepar); $this->articles_start_char[] = $wgContLang->convert( trim($sortkey,"("));
 * This let's you add text behind the closing parenthesis, by which the articles are sorted within their groups.
 * e.g.: comes before  in the 2009 section.
 * The recommended use would be, to give the pagetitle, so that the articles are in alphabetical order.
 * Sidcom 17:55, 21 February 2010 (UTC)

And what if I want a subcategory to be listed in a parent category by a different name? For example, I have Category 2009 as a subcategory of Articles, and instead of 2009 showing up on the Category:Articles page under subcategory header 2 I want it to be listed under subcategory header Year.
 * The same solution as above could be done for the sub-category listings. Modify the "getSubcategorySortChar" function on the same page to return a different result when the key is surrounded by parenthesis and then modify the category definition on the sub-category page to include the parenthesis. for example, in the 2009 category page, include the following:


 * --Dlhdesign 00:56, 22 September 2009 (UTC)

And what if I want to list the same article in the same category with multiple keys? If I do: It will only appear once on the :Category:Author page, under "A". I would like the Author page in this case to list a header "Aleph" and all pages with him listed as an author, and a separate header "Gammow" with the same.


 * I know it doesn't work to put the same category twice, even with different sort keys. In fact, there's a cleanup project that's identifying articles like that, so that it can be corrected.
 * One thing you can do (and I don't know if this fits what you had in mind) is put categories on redirect pages. Two examples are the English Wikipedia pages for Nickolas Ashford and Valerie Simpson, which both redirect to Ashford & Simpson. The redirect pages for their individual names have default sort keys for their individual names, and include categories that apply to them as individuals. One category listed on both pages is "Living people", so they'd appear separately in that category. Does that help? --Auntof6 23:14, 5 June 2009 (UTC)
 * The SQL table which stores the category links (aptly named "categorylinks") has a unique key on cl_from and cl_to, which means that a single page can only link to a particular category once. This is likely "enforced" in the parse code by using a unique key in an array or something (I didn't look for it in the code, so am not sure on that bit.) So in your example above, the "Gammow" key overwrites/replaces the "Aleph" key before it even gets saved to the DB.
 * In theory, you could further modify the "getPage" and "getSubcategorySortChar" to look for a splittable list and then have it add a unique "page" for each split item. For example, you could provide a key of "Aleph,Gammow" which would then split the key on the comma and list the page under both the "A" and "G" keys. Or (extending the above), you could provide a key of "(Aleph),(Gammow)" and it could list it under the full keys. You would likely need to decide how to deal with the key counts, since the visible number of links would be different than the true counts. I'd personally just change the text to list them as "unique pages" or the like, but there are other options there as well...
 * The final modification would then be to adjust the parser so that duplicate sort keys on the same category link result in a joined session key. This joined key would then be stored in the DB as if it had been passed in above, making your above syntax correct. --Dlhdesign 01:24, 22 September 2009 (UTC)
 * Any way the library could be interrupted through extensions? Seems it would be much better to make an extension to do this than hacking the source file that handles this.Goldbishop 01:51, 29 July 2010 (UTC)

Sort numbers by more than one character

 * I read the above "solutions" about sorting but I think I'm having a different problem.
 * e.g. I have two categories, one is called "Test 90" one is "Test 100". Those two categories belong to the category "Numbers". There they are sorted this way: T --> first "Test 100" and THEN "Test 90". So MediaWiki seems to look from character to character (and in this case numbers) which makes the sorting very wrong. Does anyone have a solution for this? This would be awesome! --SmartK 14:41, 23 August 2010 (UTC)
 * General technique that is beneficial is to use same number of digits (e.g. Test 100, Test 090), then it forces the computer to index correctly. Similarly, putting dates in a YYYYMMDD format will always group by the larger bucket, ie year, then month, then day). hope that helps.

Sorting Categories by date
By default a category page display the related items according to the letters Is it possible to change it to dates, years and months
 * The answer is no. Sorting is by alphabetical order of the sort key, always. One can do a manual approximation of a sort by "dates, years and months", providing a sort key which, when sorted alphabetically, yields the desired result. For example, articles named "A1", "A2" and "A3" categorized, respectively, with:


 * A1:
 * A2:
 * A3:


 * would be listed under Category:C in the following order:


 * A3
 * A2
 * A1


 * However, they would all be grouped under heading "2", because all the sort keys start be "2". If one of the dates is "1999 01 03", that page would be grouped under the separate heading "1" because it starts by "1". To ensure all pages were sorted under one single heading, you need to start all sort keys by the same caracter, so "*20100903", "*20100902", "*20100901" and "*19990103" would be sorted in one single groupd under heading "*" because they all start by "*". All the sort keys have to be created and maintained by users manually. Hamilton Abreu 00:27, 13 October 2010 (UTC)
 * cough dpl. (I only mention it since that was the original use case for the extension. Wikinews uses that extension extensively to give pseudo-category listings by date) You can also sort by date the category was added to the page using the api if you don't mind the non-pretty interface. Bawolff

How to remove a category
- Hello ! I cannot find it. I know that there are other rules than on the pages but is there a possibility to remove category that is no longer needed ?
 * - Simply remove all occurrences of a category on wiki pages and the category will automatically disappear. -- Satri 12:53, 18 October 2010 (UTC)

Category aliases / multi-language categories / grouping categories
- We have a wiki in multiple languages. We want some categories to be grouped together, such as a "City" category (English) and a "Ville" category (French). At the moment, the two categories are distinct. Does anyone knows how we could automatically "group" these two categories to act as a single one? (ideally without having to add the two categories to a page) Thanks. -- Satri 13:00, 18 October 2010 (UTC)

Space a sort key using DEFAULTSORT
It appears that using a single space as sort key doesn't work using the DEFAULTSORT variable, i.e. simply gets ignored. Is there some way to work around this? __Meco 22:34, 18 October 2010 (UTC)
 * Use (In case your wondering, &amp;#32; is space as space is character number 32 in ascii/unicode). I'm not sure if defaultsort should really be trimming spaces like that. This could potentially be a bug. Bawolff 03:53, 19 October 2010 (UTC)

Categories not appearing
I'm attempting to add categories to several pages on the Venture Bros. Wiki and for some reason they are not appearing. I'm typing them in correctly and everything, does anyone know how to fix this? Uncle Tyrone