[pmwiki-users] Pagelist ordering by name

Peter Bowers pbowers at pobox.com
Mon Oct 12 14:53:58 CDT 2009


On Tue, Oct 6, 2009 at 7:52 PM, Vince Admin Account
<vadmin at math.uconn.edu> wrote:
> Patrick et. al.
> My profiles group is set up with titles being full names, i.e.,
> JohnSmith for example.
> I would like a pagelist to format the output by adding a space, and in
> order of last name. Currently it does neither.
> I suppose I will have to write a custom order function, and I don't
> know how to add the space in the template either. Any suggestions as
> to where to look.

Similar to the previous solution, but even more obfiscated in the
quoting and etc.  This certainly needs simplifying, but again it works
in my brief testing:

$firstlast_pat = '/^(.*?)([A-Z][a-z]*) *$/';
SDV($PageListSortCmp['title_last_first'],
    '@strcasecmp(preg_replace(\''.$firstlast_pat.'\', \'\\2, \\1\',
($PCache[$x][\'=title\']?$PCache[$x][\'=title\']:$GLOBALS["AsSpacedFunction"]($x))),
preg_replace(\''.$firstlast_pat.'\', \'\\2, \\1\',
($PCache[$y][\'=title\']?$PCache[$y][\'=title\']:$GLOBALS["AsSpacedFunction"]($y))))');

(Make sure when you copy it into your config.php that it is only 3 lines...)

If you want to simplify the first place I would look would be at
replacing the $PCache...?...:... with a FmtPageName('{$Title}',
$pagename) -- I think this would work but I don't know the impact on
performance...

Note that "SamMcJames" will sort with "James" instead of with "McArthur".

-Peter



More information about the pmwiki-users mailing list