[pmwiki-users] pagelist pagination

Martin Fick mogulguy at yahoo.com
Wed May 16 23:05:06 CDT 2007


--- Martin Fick <mogulguy at yahoo.com> wrote:

> --- "Patrick R. Michaud" <pmichaud at pobox.com> wrote:
> 
> > On Wed, May 16, 2007 at 05:10:41PM -0700, Martin
> > Fick wrote:
> > > What if the templating engine put a special
> markup
> > > around each iteration like this:
> > > 
> > > (:iteration:)
> > > ...
...
> > Alas, I think this still has some holes in it. 

Another point that I forgot to mention in the previous
email is that the =if solution still gets nasty with
nested ifs since it implies one condition just to
check if the page should be included or not, all other
conditions would have to be nested in this (including
headers!).


Consider your template:

> >     [[#mytemplate]]
> >     (:if ! equal {<$Group} {=$Group}:)
> > 
> >     {=$Group}:
> >     (:if auth edit {=$FullName):)
> >     * {=$FullName}
> >     [[#mytemplateend]]

To use ifs to limit this, one would have to either:
(please excuse all the syntax bastardizations) :(

1)
     [[#mytemplate]]
     (:if expr ! equal {<$Group} {=$Group} &&
      {$$PageCount}} -ge {$$start} &&
      {$$PageCount}} -lt {$$end} :)
 
     {=$Group}:
     (:if expr auth edit {=$FullName) &&
       {$$PageCount}} -ge {$$start} &&
       {$$PageCount}} -lt {$$end} :)
     * {=$FullName}
     [[#mytemplateend]]

which gets real ugly real fast!  (If you don't include
the headers in the if, then you will get all the
headers all the time, not what we want)

Or: 2)
     [[#mytemplate]]
     (:template start {$$PageCount}} -ge {$$start} &&
      {$$PageCount}} -lt {$$end} :)
     (:if ! equal {<$Group} {=$Group}:)
 
     {=$Group}:
     (:if auth edit {=$FullName):)
     * {=$FullName}
     [[#mytemplateend]]

which I don't blelieve is supported and breaks down if
we use other (:template start:)s in the template.  

Or: 3)
     [[#mytemplate]]
     (:template start {=$Group}:)
     (:if expr {$$PageCount}} -ge {$$start} &&
      {$$PageCount}} -lt {$$end} :)
 
     {=$Group}:
     (:template start auth edit {=$FullName):)
     (:if expr {$$PageCount}} -ge {$$start} &&
      {$$PageCount}} -lt {$$end} :)
     * {=$FullName}
     [[#mytemplateend]]

which is not supported yet either I think (auths in
the template start)?

Which leaves 4) actual nested ifs 

     [[#mytemplate]]
     (:ifouter expr ! equal {<$Group} {=$Group} &&
      {$$PageCount}} -ge {$$start} &&
      {$$PageCount}} -lt {$$end} :)
     (:if ! equal {<$Group} {=$Group}:)
 
     {=$Group}:
     (:ifouter expr auth edit {=$FullName) &&
       {$$PageCount}} -ge {$$start} &&
       {$$PageCount}} -lt {$$end} :)
     (:if auth edit {=$FullName):)
     * {=$FullName}
     [[#mytemplateend]]

which is also ugly (if not supported) and hard to
understand, where would I put ifends?


Yikes, I see now that the "nocount" token has problems
too!

     [[#mytemplate]]
     (:if ! equal {<$Group} {=$Group}:)
     (:template nocount:) 

     {=$Group}:
     (:if auth edit {=$FullName):)
     * {=$FullName}
     [[#mytemplateend]]

will not count the first page of every group!  To get
it right, it would require something smarter like
this:

     [[#mytemplate]]
     (:if expr ! equal {<$Group} {=$Group} && 
               ! auth edit {=$FullName):)
     (:template nocount:) 
     (:if ! equal {<$Group} {=$Group}:)

     {=$Group}:
     (:if auth edit {=$FullName):)
     * {=$FullName}
     [[#mytemplateend]]

or a weighted token, the largest score wins:

     [[#mytemplate]]
     (:if ! equal {<$Group} {=$Group}:)
     (:template nocount 1:) 

     {=$Group}:
     (:if auth edit {=$FullName):)
     (:template count 2:) 
     * {=$FullName}
     [[#mytemplateend]]


Wow, this really is complicated to get right!  Makes
me like the simple (:iteration:) solutin since it gets
things mostly right,

-Martin



       
____________________________________________________________________________________Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/



More information about the pmwiki-users mailing list