[pmwiki-users] question on pagelist templates

Hans design at softflow.co.uk
Wed Apr 26 13:10:29 CDT 2006


Wednesday, April 26, 2006, 5:58:40 PM, Marco wrote:
> I am using the BlogSimple cookbook as an event list/reminder using categories.
> What I would like to do is have a page where I can list forthcoming events
> and another for past events knowing that the "event" ( == wiki page ) name
> starts with a date . I have very little experience with php coding but i am
> willing 2 learn. 
> I was thinking about using the variable '$BlogDateSimple' but have no idea on
> how to compare it with current date in a format template....

$BlogDateSimple or $BlogDate would not work, as it uses the page
creation time. So we need to make some new page variables.
Add these to blogsimple.php:

# add page variable {$BlogDate2} as date yyyymmdd with name stripped off
$FmtPV['$BlogDate2'] = 'StripName($pagename)';
function StripName($pagename) {
    $sn = preg_replace("/[^.]*\.([\d\-]*)(.*)/e","'$1'",$pagename);
    $sn = preg_replace("[\-]","", $sn);
    return $sn;
};
# add page variable {$Today2} in format yyyymmdd
$FmtPV['$Today2'] = 'strftime("%Y%m%d", time() )';

These will give us some nice dates in a numeric format.
{$BlogDate2} is derived from the page name, using the date part.

Now to make page lists for future events we add the following format
to page Blog.BlogListTemplates

!!!#futuretitles
pagelist of spaced future titles for sidebar, without group heading. 
[@
[[#futuretitles]](:if equal {<$Group}:)
>>futuretitles<<(:if:)
(:if ge {=$BlogDate2} {$Today2} :)
* [[{=$FullName}|{=$BlogTitle}]]
(:if equal {>$Group}:)
>><<(:if:)
[[#futuretitlesend]]
@]

This uses the extended conditional script from
http://www.pmwiki.org/wiki/Cookbook/ConditionalExtensions
so we need to install extendcond.php as well
(:if ge {=$BlogDate2} {$Today2} :) filters the pages with future date
strings. It will display today's page and any future page.

And finally we can use a pagelist directive in  a sidebar for
instance, like:
!!!!Future Events
(:pagelist group=BlogPages list=blog fmt=Blog.BlogListTemplates#futuretitles order=-name count=10 :)

For past events we do it similarly:

We add to page Blog.BlogListTemplates:

!!!#pasttitles
pagelist of spaced past titles for sidebar, without group heading.
[@
[[#pasttitles]](:if equal {<$Group}:)
>>pasttitles<<(:if:)
(:if lt {=$BlogDate2} {$Today2} :)
* [[{=$FullName}|{=$BlogTitle}]]
(:if equal {>$Group}:)
>><<(:if:)
[[#pasttitlesend]]
@]

And we can use a pagelist directive like
!!!!Future Events
(:pagelist group=BlogPages list=blog fmt=Blog.BlogListTemplates#pasttitles order=-name count=10 :)

Note that the #futuretitles and #pasttitles fmts are just giving links
to the pages, and do not include any page content.
More refinement in presentation may still be required.
No date is preceding the page title display.
$BlogDateSimple can't be used as we create pages with different date
strings in their names from today, so the page creation time does not
give us the page date any longer, and the date need to be abstracted
from the page name instead. This I have not done here.

Best,
 Hans                           





More information about the pmwiki-users mailing list