[pmwiki-users] pagelist pagination

The Editor editor at fast.st
Thu May 17 05:18:25 CDT 2007


For what its worth, my counter idea did not seem to work. Exactly as
Pm predicted.

I changed my template to

[[#test]]
(:template each:)
(:if expr {(counter {$$beg} {$$end})} && ! auth edit:)*
[[{=$FullName}]]{(counter +)} {(counter =)}(:if:)
[[#testend]]

And my counter functon to:

$MarkupExpr['counter'] = 'MkExpExtCounter(preg_replace($rpat, $rrep, $params))';
function MkExpExtCounter($x) {
   global $ZAPcounter;
   if ($x == " +") {
      $ZAPcounter = $ZAPcounter + 1;
      return '+';
      }
   elseif ($x == ' =') return $ZAPcounter - 1;
   else {
      $x = trim($x);
      $first = substr($x, 0, strpos($x, " "));
      $second = substr($x, strpos($x, " ") + 1);
      if (($first <= $ZAPcounter) && ($ZAPcounter <= $second)) return 'true';
      return 'false';
      }
   }

It counted the pages that were skipped--evidently because their markup
was triggered before the conditionals took effect causing the counter
to be advanced regardless of whether it passed the auth conditional. I
tried processing the counter incrementer after the conditionals but
the results were worse--it didn't even begin incrementing until late
in the game, making it completely useless.

So I guess it's a good illustration of the problem involved, even if
not a solution. And while reasonably elegant--it won't work.

To get it to, you would either have to advance the counter when the
conditional passed  and yet be useful in the next conditional (which
would mean it would have to tap into the conditional engine somehow),
or the counter has to handle things internally--working off it's own
list of pages--which is essentially what Han's solution does (via a
preliminary pagelist).

Cheers,
Dan

PS. Pm, is there any easy way to put a special tag in the conditional
engine that said basically execute a function (from some specially
defined array of acceptable ones) only if the conditional passes. If
so, it might solve the problem very nicely.  Something like:

(:if auth edit %function( )%:)

It might also have various other uses as well...



More information about the pmwiki-users mailing list