Forum:Is there a way to ignore DEFAULTSORT?

Hello again. Does anyone know of a way to ignore the magic word DEFAULTSORT? Here is my dilemma. We use DEFAULTSORT to categorize all of our character by last name, when known. We have a group of characters on the WoT Wiki that are primarily known by their first names. We also have a template that automatically adds a character's page to certain categories base on fields in the template. What we would like to do is when a certain field is used or when a certain entry on another field is used, we would like the softwear (I guess) to ignore the DEFAULTSORT for those categories only, but keep the sort key for other categories.

That may seem confusing. Let me break it down. One of the characters we have is named Alanna Mosvani. With the DEFAULTSORT, she would be listed under "M" (i.e. the sort key for her is "Mosvani, Alanna"). When one of the fields on the template on her page is used (ajah=Green), we would like it so that in the category associated with that field (Category:Green Ajah), she would be listed under "A." This is the "certain field" I mentioned above. We also have a field named "affiliation." When that field equals "Black Ajah," we would also like to have the softwear ignore the DEFAULTSORT.

I'm not sure if that is possible, but I thought I would ask. Here is a link to our character template. This would help us out greatly! Thanks! Willie -  HtS  20:01, August 27, 2010 (UTC)
 * DEFAULTSORT is just a default sort, you can still specify sort keys for individual categories the normal way (e.g., ) -- 20:23, August 27, 2010 (UTC)

The problem with that is the character template that we use automatically adds the page to various categories based on fields. These categories are not "alterable" in the normal way and they don't appear at the bottom of the page when editing. Go here and look at the bottom of the edit area. :) Willie  -  HtS  20:28, August 27, 2010 (UTC)
 * You will have to change the template to use the sort key if it is specified. -- 20:34, August 27, 2010 (UTC)

How exactly would one do that? I'm not really all that experienced with that particular template's code. Or if you have any examples you could link too. Thanks! Willie -  HtS  22:55, August 27, 2010 (UTC)
 * Here's an example for you:


 * is an example line in a template, where you categorise the page. However, if the line read:


 * then, given the argument sortcode the template would categorise the article under the sortcode, not under the page title. (Odiously, you can change the names to what would best suit your wiki) -- Random Time  23:15, August 27, 2010 (UTC)

So, we use #switch in our template. Here is where we would mainly need it I'm not entirely sure how to include what you posted. Would it be {{#if:{{{sortcode|}}}|{{#switch: {{{ajah}}}||}} In this example, "ajah" is the field name where we would specify the category. So when we use the template on a page, we would type in "|ajah=Green" and the template would put the page in. Is what I wrote going to work, or am I way off base? Thanks in advance for any help. Willie -  HtS  01:47, August 28, 2010 (UTC)
 * Depends if you only want to do the #switch if the #if evaluates as true. -- 01:50, August 28, 2010 (UTC)


 * Let's see if I get this right. Your template uses the code

{{#switch: {{{ajah}}}|}}
 * to place a character in a category, e.g. Category:Green Ajah.
 * For this category, you do not want to use the defaultsort given on the character's page, but always sort by page name. Then you could give {{PAGENAME}} as the sort key, like so:

{{#switch: {{{ajah}}}|}}


 * This will put all of the character pages with that infobox into Ajah categories by pagename and ignore the defaultsort that may be given on the character page. (The other categories of the infobox are not affected.)
 * If you only want Green Ajah to be sorted that way, you'd need more code. -- ◄mendel► 06:36, August 28, 2010 (UTC)
 * On second thought, that's a weird way to use switch. It does precisely nothing, i.e. the page will always be placed in because you are only using the default branch.
 * Did you mean this (note the extra |)?

{{#if: {{{ajah|}}}|}}
 * I've looked at your infobox template, it is impossible to read (a 40 kB template! with hardly any line breaks! there is no way I'm touching this without a major rewrite), I can't find the defaultsort on the character page nor can I find the place wherer the template creates the Ajah category. Sigh. -- ◄mendel► 06:51, August 28, 2010 (UTC)

I apologize for that template. It is a bit ungainly. We are working on trying to cut it down to size. However, your fix worked! Thank you mendel! Willie -  HtS  13:00, August 28, 2010 (UTC)

Best of both worlds - a redirect page
If the first name is better known than the LAST name for just a handful of characters (i.e. it is the exception rather than the rule) then perhaps a simpler solution is:

For each exception
 * 1) (manually) create a redirect page that is named "First LAST"
 * 2) (manually) make the content of that page simply:
 * 3) (manually) add all the same categories for this redirect page as you have already used on the primary page. e.g.

The "First LAST" page name will show up in the category index under the first letter of the First name and the "LAST First" page name will show up in that same category index under the first letter of the LAST name.

Maybe this is a better result for just that handful of characters who are better known by their first name. Redirect pages can be useful when dealing with this type of Many-to-One relationship or pagename aliases.

Good luck. -- najevi 01:47, August 28, 2010 (UTC)


 * Thanks for the suggestion, but mendel above gave me what I needed. :) Willie  -  HtS  13:00, August 28, 2010 (UTC)