[pmwiki-users] Include with a Regular Expression

Stirling Westrup sti at pooq.com
Tue Jan 15 11:10:00 CST 2008


Eric Celeste wrote:
> I don't think I can use pagelist since it has no concept of which pages 
> have recently changed and which have not.
> 
> I was going to use something like...
> 
>     (:include RecentChagnes regex="Nico-":) 
> 
> (oversimplified and nonexistent, but this is just an example) to pull 
> only lines from the RecentChanges page that are pertinent in order to 
> create a new page with just that subset of the recent changes.

There really isn't a good way to extract subsections of a page the way 
you are thinking. Even if there was, you'd need a much more complex 
regex as you'd want to end up grabbing the entire line containing a 
given reference, not just the matching text, and you'd need to ensure 
you didn't include a change to the wrong page, just because the summary 
of the change mentioned some other page.

What most folks do in circumstances like this is to put some code in 
their config.php file to change which pages get change-summaries written 
to. Something like this:

$page = PageVar($pagename, '$FullName');
if( preg_match('/^SomeGroup.Nico-/', $page) )
   $RecentChangesFmt['SomeGroup.RecentChanges-Nico']
     = '* [[{$Group}.{$Name}]]  . . . $CurrentTime [=$ChangeSummary=]';

Then you simply use the contents of RecentChanges-Nico when you want 
those specific pages.



More information about the pmwiki-users mailing list