[pmwiki-users] Arbitrary filtering for (:pagelist:) - is there a better way?

The Editor editor at fast.st
Tue Jul 18 08:04:33 CDT 2006


Not sure I understand what you are trying to do, but it sounds like
you could just use wildcards.  From the pagelist documentation, it
uses this example:

    # All pages in the PmCal group with names starting with "2005":
    (:pagelist name=PmCal.2005* :)

So in your case you could perhaps try

    (:pagelist YourGroup.Event-2007*:) for all pages in that year...
Or even maybe
    (:pagelist *.Event-2007*:)   Haven't tried this though.

Hope this helps!

Cheers
Caveman



On 7/18/06, Michael Tempest <michael.tempest at ate-aerospace.com> wrote:
> Hi
>
> I have pages in my PmWiki that are applicable to a specific date, like a
> calendar. I've encoded the data in the name (for example "Event-2006-07-13"),
> which lets me order by name (or -name) and the pages are ordered by date. (I
> can't use creation date or last-modified date - these pages may be created in
> any order and will often be modified after the applicable date.)
>
> So far, it works without a problem.
>
> I want to list pages for future dates or for past dates. I cannot think of a
> regular expression that would let me do that - I think actual code is
> necessary.
>
> I added a "filter" option to MakePageList() in pagelist.php, configured with a
> new global called $SearchFilterFunctions. Here is the modification to
> MakePageList():
>     ....
>     if (@$opt['trail']) {
>     ...
>     } else $list = ListPages($pats);
>
> >    if (@$opt['filter']) {
> >        if (function_exists(@$SearchFilterFunctions[$opt['filter']])) {
> >            $list = $SearchFilterFunctions[$opt['filter']]($list);
> >        }
> >    }
>
>     if (IsEnabled($EnablePageListProtect, 1)) $readf = 1000;
>     $matches = array();
>     $FmtV['$MatchSearched'] = count($list);
>     ....
>
> Here is an example of how I use it (from config.php):
>   # This is accessible as (:pagelist filter=future:)
>   $SearchFilterFunctions['future'] = 'SearchFilterFuture';
>   function SearchFilterFuture(&$input_list)
>   {
>       $output_list = array();
>       foreach ($input_list  as $page)
>       {
>           if (preg_match('/(\d\d\d\d-\d\d-\d\d)/', $page, $matches))
>           {
>               $event_date = $matches[1];
>               $today = date("Y-m-d");
>               if ($event_date >= $today)
>               {
>                   $output_list[] = $page;
>               }
>           }
>           else
>           {
>               $output_list[] = $page;
>           }
>       }
>       return $output_list;
>     }
>
> This all works. My question is - is there a better way?
>
> 1) Is there a way to do with without modifying pagelist.php?
>
> 2) I'm not very familiar with php's array functions (in fact, PmWiki is my
> first encounter with php), so is there a better way to reduce the list than
> "$list = $SearchFilterFunctions[$opt['filter']]($list);" ?
>
> 3) I've not been working with (:pagelist:) for very long. As a generalisation,
> is it better to be inclusive or exclusive with pagelists and the like? I've
> chosen to include pages that don't match the desired form. Would it be better
> to exclude them?
>
> Have a great day
>
> Michael
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://host.pmichaud.com/mailman/listinfo/pmwiki-users
>




More information about the pmwiki-users mailing list