Difference between revisions of "Sort articles on people by last name"

From FollowTheScore
Jump to: navigation, search
(New page: '''This page explains how article on people can be sorted by the last name of people although the articles' names sound like "FirstName(s) LastName".''' ---- This is a listing of all art...)
 
Line 37: Line 37:
 
To improve readability we can use our special characters for pipe and newline. And the  
 
To improve readability we can use our special characters for pipe and newline. And the  
 
whole thing will be easier to use if we put the code into a separate template which takes the category as an argument.
 
whole thing will be easier to use if we put the code into a separate template which takes the category as an argument.
Then the only thing we have to write is
+
We also should use a reasonable message text if htere are no articles in the category under question. Then the only thing we have to write is
  
 
<pre><nowiki>
 
<pre><nowiki>
Line 46: Line 46:
  
 
{{list articles on people by last name|Fictional Character}}
 
{{list articles on people by last name|Fictional Character}}
 +
 +
Looking for an empty category <tt>xyz</tt> would provide the result: {{list articles on people by last name|xyz}}

Revision as of 16:37, 15 August 2008

This page explains how article on people can be sorted by the last name of people although the articles' names sound like "FirstName(s) LastName".


This is a listing of all articles which describe members of the category "Fictional Character".

As you can see you will get a listing which is ordered by the first name as this is also the title of the respective articles.

With "replaceintitle" you can manipulate the appearance of the names but the order will still be determined by the article names and not by the changed label:

So we must create a sortable list which allows the user to click once for a LastName ordering:

{{#dpl:
 |replaceintitle=/([A-Za-z ]*)( [A-Za-z]+)$/,\2, \1
 |category=Fictional Character
 |format={{(!}}class=sortable\n!Fictional Characters\n{{!}}-,\n{{!}}[[%PAGE%{{!}}%TITLE%]],\n{{!}}-,\n{{!)}}
}}

which will produce the following:

Fictional Characters
Potter, Harry
Granger, Hermione Jean

To improve readability we can use our special characters for pipe and newline. And the whole thing will be easier to use if we put the code into a separate template which takes the category as an argument. We also should use a reasonable message text if htere are no articles in the category under question. Then the only thing we have to write is

{{list articles on people by last name|Fictional Character}}

And we will get the same result as above:


Fictional Characters
Potter, Harry
Granger, Hermione Jean


Looking for an empty category xyz would provide the result:

Fictional Characters
2007-12-01 Meeting,