[pmwiki-users] pagelist format templates and page variables

Hans design at softflow.co.uk
Sun Feb 19 17:44:04 CST 2006


Sunday, February 19, 2006, 7:34:27 PM, Patrick wrote:
> Is {$PostCount} smart enough to know that it should be reading
> from BlogComments, or is it just working on whatever page it has?

okay, I tried various things and now I am stuck.
The problem may not be with pagelist's handling of page variables, but
with {$PostCount}  itself.

It works fine on a page with comments, counting the >>messagehead<<
string occurrences on the page. But if it is used from a different
page like {SomePage$PostCount} it returns not the number of string
occurences in SomePage, but in the current page.

The code is:

   $FmtPV['$PostCount'] = 'StringCount($pagename,">>messagehead<<")';

   function StringCount($pagename,$find) {
      $page = ReadPage($pagename, READPAGE_CURRENT);
      return substr_count($page['text'], $find);
   }

What do I need to change?


Best, 
~Hans                           





More information about the pmwiki-users mailing list