[pmwiki-users] experimental - pagelist conditionals

Patrick R. Michaud pmichaud at pobox.com
Tue May 1 22:58:56 CDT 2007


I'm experimenting with a couple of new features, and looking
for feedback.

1.  Extension to (:if date ... :)

Currently the 'date' conditional can only be used to test
that the current time is in a range of dates.  For example,
to display some text only if the current date is between
March 15 and May 2 inclusive, one can write:

    (:if date 2007-03-15..2007-05-02 :)

I've added an extra parameter to the 'date' conditional,
so that times other than the current time can be tested.
For example, to check if the current page's name is
in the month of May 2007, one can write:

    (:if date 2007-05-01..2007-05-31 {*$Name} :)

Thus, this would evaluate to true for pages with names
like "20070512" or "2007-05-31", but false for pages
with names like "2007-04-30" or "2008-05-15".

Also, date ranges now understand phrases like "today",
"tomorrow", "now", etc.


2.  if= option to (:pagelist:)

I'm also looking at the possibility of adding a new 
if= option to pagelist.  The contents of any if= option 
are treated as a conditional markup (same as the "(:if:)" 
directive) to be evaluated; only pages that evaluate
to "true" are kept in the pagelist.  Thus, combined with
the above, one can write:

    (:pagelist if="date today.. {=$Name}" :)

This returns a list of all pages with names that
correspond to dates today or later.  Some other
examples that become possible with this:

- Display all pages with names in the current month
    (:pagelist if="date {(ftime %Y-%m)} {=$Name}" :)

- Display all pages in PITS that were created in 2006
    (:pagelist group=PITS $:Created=?* if="date 2006-01..2006-12 {$:Created}" :)

- Display only pages for which the visitor has edit permission
    (:pagelist if="auth edit {=$FullName}" :)

Of course, using if= in (:pagelist:) will be somewhat
more efficient than (:if:) conditionals in a pagelist
template, and it also makes it easier to add count=
and other conditions on the resulting list.

Examples also appear at

   http://www.pmwiki.com/wiki/Test/PageListIf

Comments welcomed.

Pm



More information about the pmwiki-users mailing list