[pmwiki-users] HTML cache

Patrick R. Michaud pmichaud at pobox.com
Sun Jun 10 14:58:38 CDT 2007


On Sun, Jun 10, 2007 at 09:15:39PM +0200, Christophe David wrote:
> >Essentially, a custom formatting function will generally look like:
> >Hope this helps -- let me know if you need any further hints.
> 
> Thanks a lot.  I just copied your example and it works great.
> 
> Could you please show me how to convert the following parts of a
> pagelist template
> 
> {{=$Group}/{=$Name}$:MyPageTextVariable}
> 
> to $itemfmt = "<li> ... </li>\n";

FWIW, a much faster version of the above would be 

    {=$:MyPageTextVariable}

To create a set of list items consisting solely of $:MyPageTextVariable:

  foreach($matches as $m) {
    $ptv = PVSE(PageVar($m, '$:MyPageTextVariable'));
    $out .= "<li>$ptv</li>\n";
  }

> and how to determine in the custom function whether a PageTextVariable
> in another page is defined or not.  Currently, done with the ugly
> (:if equal x{MyGroup/MyPage$:MyPageTextVariable} x xx :)

To determine if a page variable for a page $m is set or not:

     $ptv = PVSE(PageVar($m, '$:MyPageTextVariable'));
     if ($ptv != '') { ... }

Combining both of the above into a loop:

  foreach($matches as $m) {
    $ptv = PVSE(PageVar($m, '$:MyPageTextVariable'));
    if ($ptv != '')  $out .= "<li>$ptv</li>";
  }

This will create a list of the values of $:MyPageTextVariable
for every page in the pagelist, skipping over the pages on which
$:MyPageTextVariable is not defined or has an empty value.

Pm



More information about the pmwiki-users mailing list