[pmwiki-users] Number of results of a pagelist query ?

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 1 23:35:29 CST 2007


On Wed, Feb 28, 2007 at 03:28:59PM -0800, Martin Fick wrote:
> ... With > the new enhancements which Patrick has proposed this
> will eventually look like this:
> 
> [[#PageCount]]
> (:template last:)
> * PageCount: {$$PageCount}
> (:template nopages:)
> * PageCount: 0
> [[#PageCountEnd]]
> 
> and be much more efficient too!

Upon seeing this I'm wondering if (:template first:)
and (:template last:) should be displayed even if the 
pagelist is empty.  Consider:

    [[#template]]
    (:template first:)
    Results of your query:
    (:template each:)
    * [[{=$FullName}]]
    (:template last:)
    Found {$$PageCount} pages.
    [[#templateend]]

I think that most people would expect the above to
go ahead and display "Results of your query:" and
"Found NN pages." even when the pagelist is empty.
And making someone repeat these lines in an separate
(:template empty:) section feels wrong somehow.

So, if we did this, then the pagecount template would
simply be:

    [[#pagecount]]
    (:template last:)
    PageCount: {$$PageCount}
    [[#pagecountend]]

Of course, someone might then say that they want to
display only the "empty" section and skip any first/last
component.  This could be done by adding a constant
string argument (e.g., 'page') to the first and last
directives, as in:

    (:template first:)
    Displayed at beginning of list (even if list empty)
    (:template first page:)
    Displayed only for first page in non-empty list.
    (:template each:)
    Displayed for every page in list.
    (:template last page:)
    Displayed only for last page in non-empty list.
    (:template last:)
    Displayed at end of list (even if list empty)
    (:template empty:)
    Displayed only if list is empty

(There's no special handling going on here -- the 'page'
argument acts just like {=$Group} or any other control break, 
but being a constant string it would have the same value
for all pages.)

Thoughts?

Pm




More information about the pmwiki-users mailing list