[pmwiki-users] pagelist template brainstorming

Patrick R. Michaud pmichaud at pobox.com
Sun Feb 18 09:05:32 CST 2007


On Sun, Feb 18, 2007 at 10:54:42PM +1100, Kathryn Andersen wrote:
> On Sun, Feb 18, 2007 at 11:52:34AM +0100, Hlad??vka Ji???? wrote:
> > When pagetextvariables are now to our disposition we can filter and sort 
> > on them.
> > Then the template should enable such a structure:
> > #template
> > (:first:)  ... start of the pagelist
> > (:first {=$:1stgroupingkey}:)  ... start of the highest level group
> > (:first {=$:1stgroupingkey}{=$:2ndgroupingkey}:)  ... ... start of the 
> > next level group
> > ...
> > (:each :)  ...  record level (single page)
> > ...
> > (:last {=$:2ndgroupingkey}{=$:2ndgroupingkey}:) 
> > (:last {=$:1stgroupingkey}:) 
> > (:last:)
> > #templateend
> 
> Yes, that probably fits better than (:each $var:) because we are really
> actually interested in the first time the $var changes...

I'll have to think about this one a bit.  When I first put
this together it seemed more natural to think in terms of
"each group", "each day", "each title letter", etc.
as opposed to "first group", "first day", "first title letter".

Yes, I know that in the above formulation it's really
"first page in group", "first page on day", "first page with
title letter", but somehow it doesn't quite read that way.
Maybe I just need to get used to it.

And on the programming side, figuring out the "last" conditions
might be a bit tricky, since doing so requires going ahead and
processing values for the next record in the list (which in itself
might require a _two_ record lookahead if there are any {>$...}
page variables in the last condition).

Still, the more I think about it the more I'm warming up to
the idea.  Returning to my original template for discussion,
suppose we wanted to display the number of pages in each group?
Without (:last {=$Group}:), we'd use a conditional, like:

    [[#template]]
    (:first:)
    ||width=100%
    ||!Page         ||!Author            ||!Modified        ||
    (:each {=$Group}:)
    ||{=$Group}     ||||||
    (:each:)
    ||{=$FullName}  ||{=$LastModifiedBy} ||{=$LastModified} ||
    (:if ! equal {=$Group} {>$Group} :)
    ||  {$$GroupPageCount} pages in group||||||
    (:last:)
    {$$PageCount} pages.
    [[#templateend]]

With (:first {=$Group}:)/(:last {=$Group}:) it would be:

    [[#template]]
    (:first:)
    ||width=100%
    ||!Page         ||!Author            ||!Modified        ||
    (:first {=$Group} :)
    ||{=$Group}     ||||||
    (:each:)
    ||{=$FullName}  ||{=$LastModifiedBy} ||{=$LastModified} ||
    (:last {=$Group} :)
    ||  {$$GroupPageCount} pages in group||||||
    (:last:)
    {$$PageCount} pages.
    [[#templateend]]

Hmmm... reactions and comments?

(Sidenote:  A couple of things to keep in mind is (1) a template author is
always free to do advanced sorts of groupings using (:if:)
conditionals, as we have been doing before now, and (2) I still
consider pagelist templates to be a somewhat advanced feature
for authors, so it's okay if things are a little cryptic at times.)

Pm



More information about the pmwiki-users mailing list