[pmwiki-users] How to to use a page count in a conditional

Peter Bowers pbowers at pobox.com
Sat Mar 28 05:33:12 CDT 2009


The "if" rule occurs fairly early on, during "fulltext" processing.  The
"pagelist" rule fires much later, during "directive" processing.  Thus the
pagelist results are not available at the time the conditional is evaluating
them.

One possibility would be to create another pagelist markup which fired
earlier:

Markup('earlypagelist', '<if',
  '/\\(:earlypagelist(\\s+.*?)?:\\)/ei',
  "FmtPageList('\$MatchList', \$pagename, array('o' => PSS('$1 ')))");

Then in your page source you would do something like this:

"(:pagellterist group=null fmt=count:)"
(:if equal "(:earlypagelist group=null fmt=count:)" "0":)
This pagelist has zero results.
(:ifend;)

Any existing pagelists would continue to be served by the normal
(:pagelist:) markup, but you could use this (:earlypagelist..:) whenever you
needed to compare the results using a conditional.

Another possibility would be to use markup expressions and the pagelist
found in powertools.

Probably the best alternative is Hans's new fpltemplate recipe (the status
is still experimental, but it's been pretty solid in my testing).  It gives
a (:template none:)  option you can put in your pagelist formatting template
as well as exposing a {$$PageListCount} variable for use in templates.

-Peter

2009/3/28 Randy Brown <randy at brownragfilms.com>

> I'd like to test whether a pagelist will yield results. If I use this
> markup: "(:pagelist group=null fmt=count:)" (:if equal "(:pagelist
> group=null fmt=count:)" "0":) This pagelist has zero results. (:ifend;) only
> "0" displays, not "This pagelist has zero results." Is there a way to use a
> page count in a conditional?
> Randy
>
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20090328/3864d069/attachment.html 


More information about the pmwiki-users mailing list