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)

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)

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)