Open main menu

UESPWiki β

UESPWiki:Archive/CP DEFAULTSORT

< UESPWiki:Community Portal
This is an archive of past UESPWiki:Community Portal discussions. Do not edit the contents of this page, except for maintenance such as updating links.

DEFAULTSORT

The wiki software's new {{DEFAULTSORT}} feature came up in the previous discussion, but since it's really an independent question, I thought I'd start a new topic to discuss it.

The background, for those not familiar with the gory details of Categories, is that on every category page on the site, the listed pages are sorted by a "sort key". By default, this sort key is set to be the page's full name. So this page, for example, by default would be sorted under "U" for "UESPWiki". Although this default works well on Wikipedia, UESP's Namespaces pretty much mess everything up. Take Category:Oblivion-Quests, for example. By default every single page in that category would be listed under "O" for "Oblivion".

The reason that all the pages on Category:Oblivion-Quests are not listed under "O" is because we override the default sort key on every page on the site. What that means is that in the template (e.g., Template:Oblivion Quests Trail), the tag that categorizes the page is specified as:

[[Category:Oblivion-Quests|{{PAGENAME}}]]

The {{PAGENAME}} part overrides the default sort key and instead tells the category to sort according to the page's basic name (without the namespace) instead of the full name.

The reason for all this preamble is that with the last upgrade to the software a new option was introduced that provides an alternative way set the category sort keys, namely {{DEFAULTSORT}}. The end result is the same with either our existing system or with the new DEFAULTSORT system, but after mulling things over I think there are advantages to the new system that may make it worthwhile to switch over.

To test things out, I've (partially) implemented the new system on Category:Oblivion-Places. So the template Template:Oblivion Places Trail specifies the category using:

[[Category:Oblivion-Places]] {{DEFAULTSORT:{{PAGENAME}}}}

So instead of overriding the default sort key within the category tag, the category tag is now simplified and instead the DEFAULTSORT part is used to override the sort key.

At first look, the new system is more complicated (two commmands, more code) and you end up with the same final result. So why bother? Because using the new system, it's easier for everyone to deal with the special cases and exceptions that inevitably occur. What prompted me to experiment with this today was the new effort to add region tags to Oblivion place pages. Emerald Melios started adding region tags using the basic format, namely [[Category:Oblivion-Places-Gold Coast]]. Which is exactly how you'd do it on wikipedia, and is how 95% of UESP editors add categories. But by default it means all the pages would be sorted under "O", which isn't optimal. So I had the option of going through and editing a half dozen pages to change the tag to [[Category:Oblivion-Places-Gold Coast|{{PAGENAME}}]]. Instead I chose to make a single edit to the template page, instead. By adding DEFAULTSORT to the template, all of the other pages were immediately fixed. And any future categories added to any place page will also now work.

The other example of how DEFAULTSORT makes things easier is on pages such as Oblivion:The Assassinated Man. This is one of many cases where actually sorting by PAGENAME isn't best; the sort key should be "Assassinated Man, The" instead of "The Assassinated Man". To fix the page currently requires adding the categories to the page a second time:

[[Category:Oblivion-Quests|Assassinated Man, The]]
[[Category:Oblivion-Quests-Dark Brotherhood|Assassinated Man, The]]

With DEFAULTSORT, all that has to be added to the page is:

{{DEFAULTSORT:Assassinated Man, The}}

DEFAULTSORT is much shorter and also gets rid of a problem that always drives me crazy when I'm doing these tags: you don't need to start by getting a list of all the categories used on that page. No matter what quest categories or other categories are used on the page, a single DEFAULTSORT will cover it.

In my experiments I just confirmed that this really will all work. DEFAULTSORT can be set multiple times in a page; the last setting on the page is the one that works. So there could be some complicated nest of templates that add various categories and automatically set DEFAULTSORT one or more times. A manual setting of DEFAULTSORT can then be added to the article and it will override all other DEFAULTSORT commands, and that manual one will be used for every category on the page (or at least, for every category that does not explicitly set its own sort key). The only caveat is that the manual setting has to come after all the template settings. For a demonstration, see Oblivion:Fort Strand, which is now being sorted as "Strand, Fort" on both Category:Oblivion-Places and Category:Oblivion-Places-Gold Coast (as for whether or not it really should be sorted as "Strand, Fort", I'm inclined to think not, but that's another question :) ).

I think starting to use DEFAULTSORT will in the long run be easier for everyone. The downside is that every single template that inserts categories will need to be modified. I'm not proposing that we immediately go through and revamp all the templates. Instead, what I'd like to propose is that whenever categories are being updated for whatever reason, those categories get changed over to the new DEFAULTSORT system. Basically, all existing category tags that have been added to articles will continue to work the same way as the changeover gradually happens. The only thing that will not work is any new DEFAULTSORT tags that are added to individual articles whose templates haven't been updated. In other words, the old system will work fine; new system will slowly work better and better as it gets more widely implemented.

As usual: any questions, comments, objections, etc? --NepheleTalk 19:16, 31 July 2007 (EDT)

Addendum: In researching categories and sorting I also just learned a new little trick that we may want to start using with subcategories of large categories. It used to be that if you pulled up Category:Oblivion-Places, the first page of the category listing would only display the first 8 subcategories, namely the A-G subcategories. The H-T subcategories showed up on the second page, with the H-T articles. This is an old problem that leads to a lot of confusion. People would assume that there were only 8 subcategories total, and wonder why, for example, there wasn't an Oblivion-Places-Mines subcategory (when there is, it just wasn't showing up where people were looking for it). By adding a space to the start of the sort key, e.g. [[Category:Oblivion-Places| Mines]] instead of [[Category:Oblivion-Places|Mines]], I was able to make all the subcategories get shown together on the first page. Is it worth keeping the change? Should it be done elsewhere (i.e., combine Category:Oblivion-NPCs and Category:Oblivion-NPCs-by-Race)? --NepheleTalk 20:13, 31 July 2007 (EDT)
One problem I've run into involving this feature. With the Morrowind quests, at least, the categories are all defined by the trail templates, and all use {{PAGENAME}} by default. This is fine except in cases where the quest's name starts with "A", "An" or "The", e.g. Morrowind:The Code Book. Now, I added the DEFAULTSORT tag to the page, but it still sorts under 'T' and not 'C'. The PAGENAME in the trail seems to override the DEFAULTSORT on the page. Now I could change the trail to not use PAGENAME anymore, but then all the quest pages that DON'T have a DEFAULTSORT tag on them would end up sorting under 'M'. So in order for this feature to be used at all, we'll have to change every single quest page so that they all have a DEFAULTSORT on them. Ideally, only the pages that start with "A", "An" or "The" should need to use this feature. It shouldn't be necessary to use it on every single quest page. Is there another solution to this problem? --TheRealLurlock Talk 14:37, 24 August 2007 (EDT)
That's exactly what I was trying to explain with my original post. DEFAULTSORT won't work until the bread crumb trails are changed. See Template:Oblivion Places Trail for an example of how the bread crumb trails need to be set up if we want to start using DEFAULTSORT. --NepheleTalk 14:45, 24 August 2007 (EDT)
And now I've updated Morrowind Fighters Guild Trail, too. You can confirm in Category:Morrowind-Quests and Category:Morrowind-Quests-Fighters_Guild that Morrowind:The Code Book is now correctly sorted without having to edit any other quest pages that use that bread crumb trail. I really don't see what's so difficult about implementing this change or why you think some other approach needs to be invented. --NepheleTalk 15:13, 24 August 2007 (EDT)
Oh! Okay, sorry, I wasn't quite understanding it from your description. Didn't occur to me that DEFAULTSORT and PAGENAME could work together like that. It only works if you specifically DON'T specify category placement, as that overrides the DEFAULTSORT. Got it now. Sorry about the confusion... --TheRealLurlock Talk 19:31, 24 August 2007 (EDT)