[pmwiki-users] Adding a Reply Count to SimpleForum Cookbook
Hans
design at softflow.co.uk
Sun Feb 19 12:15:33 CST 2006
Saturday, February 18, 2006, 10:12:48 PM, DaveG wrote:
> 3] Add functions to create the link to the discussion page, and count
> the posts in the discussion page. The count is based on the number of
times the markup ">>>messagehead<<" occurs on the page.
> I created a two functions in my skin .php file:
> function FindInPage($pagename,$find) {
> $p = ReadPage($pagename, READPAGE_CURRENT);
> return substr_count($p['text'], $find);
> }
thanks for this idea!
I used it to create a simple post counter for commentboxstyled.php.
I added to the script the following:
# add page variable {$PostCount},
# counts message items per page
$FmtPV['$PostCount'] = 'StringCount($pagename,">>messagehead<<")';
function StringCount($pagename,$find) {
$p = ReadPage($pagename, READPAGE_CURRENT);
return substr_count($p['text'], $find);
}
Then one can use the new page variable {$PostCount} on any comment
page or in a pagelist format template (I've done it for the simple
forum), which shows the number of posts on the page.
A forum pagelist format template with an extra column for posts
counted can look like this:
!!!fmt=#forum
forum topics in table format
[@
[[#forum]]
(:if equal {<$Group}:)
(:table class=forum width=100% :)
(:cell style="background:#e5e5ff;padding-left:5px" :)'''Topic'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''Posts'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''Last Posted'''
(:cell style="background:#e5e5ff;padding-left:5px" :)%thd%'''By''' (:if:)
(:cellnr style="background:#eeeeff;padding-left:5px" :)[[{=$FullName}|+]]
(:cell style="background:#eeeeff;padding-left:5px" :){=$PostCount}
(:cell style="background:#eeeeff;padding-left:5px" :){=$LastModified}
(:cell style="background:#eeeeff;padding-left:5px" :){=$LastModifiedBy}
(:if equal {>$Group}:)
(:tableend:)(:if:)
[[#forumend]]
@]
Best,
~Hans
More information about the pmwiki-users
mailing list