[pmwiki-users] pagelist order=month?

Peter Bowers pbowers at pobox.com
Fri Sep 4 09:20:31 CDT 2009


Here's a quick shot at modifying the examples on that page...

On the wiki page:
(:pagelist order=yearmonthday:)

In your config.php:

$PageListSortCmp['yearmonthday'] = 'YearMonthDayComp($x, $y)';
$Months = array ('jan'=>1, 'feb'=>2, ..., 'dec'=>12);

function YearMonthDayComp($x, $y) {
      ## compare the $:Year values
      $c = strcmp(PageVar($x, '$:Year'), PageVar($y, '$:Year'));
      if ($c != 0) return $c;

      ## compare the $:Month values
      $c = $Months[strtolower(PageVar($x, '$:Month'))] -
$Months[strtolower(PageVar($y, '$:Month'))]
      if ($c != 0) return $c;

      ## compare the $:Day values
      $c = intval(PageVar($x, '$:Day')) - intval(PageVar($y, '$:Day')));
      return $c;
}

Note that I'm not sure whether I should be subtracting y from x (as
I've done) or x from y for the month and day comparison.

Note also that I'm assuming you've got exactly 4 digits for years and
that they are entered consistently.  If the month is misspelled or
something then undesired results will occur without any error messages
(or perhaps ugly PHP error messages), etc.

-Peter

On Fri, Sep 4, 2009 at 9:37 AM, Graham Archer<Graham.Archer at sun.com> wrote:
> Hi:
>
> re:  I think http://www.pmwiki.org/wiki/PmWiki/CustomPagelistSortOrder will
> help...
>
> I'm not sure. I'm not that technical and some of this is hard for me to
> understand.
>
> I guess what I need is similar functionality that order=time gives, since it
> sorts by date/time based on date the page was changed.
> I would need this same sort functionality but based on the PTV {$:month}
> rather than the date/time the page was changed.
>
> But I don't know how to do this.
>
> rgds
>
> Graham
>
>
> Peter Bowers wrote:
>
> On Fri, Sep 4, 2009 at 8:15 AM, Graham Archer<Graham.Archer at sun.com> wrote:
>
>
> I would like to use pagelist  and order the pagelist by the Month page
> text variable - i.e
>
> order=month lists ....  Jan,Feb,Mar,Apr ..etc
> order=-month lists .... Dec,Nov,Oct,Sept ....etc
>
> I can't figure out a way to order the pagelist other than alphabetically
>
>
> I think http://www.pmwiki.org/wiki/PmWiki/CustomPagelistSortOrder
>  will help...
>
> -Peter
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>



More information about the pmwiki-users mailing list