[pmwiki-users] Order pagelist with Hans' PowerTools {(wordcount)}

antony templier antony.templier at gmail.com
Tue Sep 18 20:32:55 CDT 2012


ABClf <languefrancaise <at> gmail.com> writes:

> 
> Hi !
> 
> I cant succeed to order my pagelist with wordcount (from Han's
> PwoerTools recipe) ;
> does anyone know the syntax to be used ?
> 
> [[#nmots]]
> * [[{=$FullName}]] {(wordcount [[{=$FullName}]])}
> [[#nmotsend]]
> 
> (:pagelist Group=Argot name=D* fmt=#nmots count=10 order=??????:)
> 
> Thank you !
> 
> Gilles.
> 

Add this to your local/config.php just after 
including the powertools.php like this:

include_once("$FarmD/cookbook/powertools.php");

function CountWordCompare($x, $y) {

    # get word count of the page
    $xval = WordCount( $x );
    $yval = WordCount( $y );


    # compare integer values
    if($xval > $yval) $c = 1;
    elseif($xval < $yval) $c = -1;
    else $c = 0;
    return $c;
}
$PageListSortCmp['countword'] = 'CountWordCompare($x, $y)';

and in your wikipage use:

(:pagelist Group=Argot name=D* fmt=#nmots count=10 order=countword:)

or to reverse order :

(:pagelist Group=Argot name=D* fmt=#nmots count=10 order=-countword:)

hope that's help,
Antony





More information about the pmwiki-users mailing list