[pmwiki-users] pagelist for group default pages

Patrick R. Michaud pmichaud at pobox.com
Thu Nov 8 13:42:06 CST 2007


On Thu, Nov 08, 2007 at 07:17:58PM +0000, Hans wrote:
> Thursday, November 8, 2007, 4:59:08 PM, The Editor wrote:
> 
> > Do you have an option to be able to do something like
> 
> > (:pagelist pattern='/^([a-zA-Z]+)\.1$/' :)
> 
> > I do something similar and find it very useful. And it seems quite fast.
> 
> Sure you do! Patterns can be set in php as additions to the
> $SearchPatterns array. With that one can define new list= values, or
> modify existing ones. Mostly used to exclude pages from being listed.

Oh, silly me ... thank you Hans for pointing out what should've
been obvious to me!  We can do

   $SearchPatterns['homes'][] = "/^($GroupPattern)\.(\$1|$DefaultName)$/";

and then (:pagelist list=homes:) returns a list of any group "home" 
pages that fit the Group.Group or Group.$DefaultPage naming pattern.
Of course the pagelist can then be further filtered using name=,
group=, or other filtering criteria.

Now that I've seen this, something like it is very likely to go
into the core.

Dan's suggestion for "pattern=..." is also an excellent one
that I'm considering, although there's a good possibility I will 
call it "regex=" instead to avoid confusion with wildcard patterns.
Thus we'd have something like

    (:pagelist regex="^(.+)\.$1$" :)


I'm still on the fence as to whether the patterns should include
the slashes.

Lastly, I'll note that this already exists as a deprecated feature
in PmWiki, using the 'match' conditional as

    (:pagelist if="match ^(.+)\.$1$" :)

The reason this is deprecated is that the 'match' conditional
is likely to become 'regex', again to indicate that it's using
regular expression syntax instead of wildcard syntax.  The
conditional is also likely to generalize to allow regular
exprssion matches against any string (currently it only
matches pagenames):

    (:if regex "pattern" "string containing pattern" :)

Thanks for the terrific suggestions!

Pm



More information about the pmwiki-users mailing list