On 2017-07-18 21:36, Pete Lomax wrote:
Hi there, first time poster here.

I've got VoteCounter working, apart from the pagelist order, and I'm
looking at CustomPagelistSortOrderFunctions - but I think the problem
is that VoteWeightedSum is a pagevar, not a pagetextvar.

Can the equivalent of IntegerDataCompare be done for VoteWeightedSum?

Yes, it can. Something like this:

  # sorting pages by numerical integer pagevar data
  function IntegerPVCompare($x, $y, $var) {
    # get integer value of the page text variable
    $xval = intval(PageVar($x, $var));
    $yval = intval(PageVar($y, $var));
    # compare integer values
    if($xval == $yval) return 0;
    return ($xval > $yval) ? 1 : -1;
  }

  # order=votes to sort numerically by {$VoteWeightedSum}
$PageListSortCmp['votes'] = 'IntegerPVCompare($x, $y, "$VoteWeightedSum")';

  # order=votecount to sort numerically by {$VoteCount}
$PageListSortCmp['votecount'] = 'IntegerPVCompare($x, $y, "$VoteCount")';

Use order=-votecount to see those with most votes on top.

Petko

---
PmWeekly Blog  :  http://www.pmwiki.org/wiki/News
Change log     :  http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes  :  http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade :  http://www.pmwiki.org/wiki/PmWiki/Upgrades

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to