[pmwiki-users] pagelist sorting
Hans
design5 at softflow.co.uk
Tue Mar 6 04:34:48 CST 2007
Monday, March 5, 2007, 11:46:06 PM, Hans wrote:
> for the pagelist order= functions, PmWiki allows the creation of custom
> order functions. See
> http://www.pmwiki.org/wiki/PmWiki/CustomPagelistSortOrder
> Maybe a custom function can be created which would process a page
> text variable to create a numeric page order.
> order=Books a la method 2.
Here is a custom PagelistSortOrder function for sorting pages by numerical
pagetextvar data:
Add to local config (or recipe script:
# sorting pages by numerical pagetext var data
function NumericDataCompare($x, $y, $var) {
# get integer value of the page text variable
$xval = intval(PageTextVar($x, $var));
$yval = intval(PageTextVar($y, $var));
# compare integer values
if($xval > $yval) $c = 1;
elseif($xval < $yval) $c = -1;
else $c = 0;
return $c;
}
# defining order=books to sort numerical by pagetextvar $:Books
$PageListSortCmp['books'] = 'NumericDataCompare($x, $y, "Books")';
Then use in your pagelist directive with order=books (numerical sort
smallest number first) or order=-books (largest number first)
For other page text variables just create another array item for
$PageListSortCmp, as done above with "Books"
Hans
More information about the pmwiki-users
mailing list