[pmwiki-users] Adding a Reply Count to SimpleForum Cookbook
DaveG
pmwiki at solidgone.com
Sat Feb 18 16:12:48 CST 2006
Just thought I'd share how I've implemented the Cookbook/SimpleForum.
Each page has a tabbed link to a discussion page, which also includes a
count of the number of posts on the page. For a sample refer to
http://mr2wiki.com/Main/TopicRequests.
Each page has a tabbed Discuss link. This points to a page in the group
Forum named "Group-Pagename". The Discuss tab is replaced with a Return
tab when viewing the Forum to allow the user to return to the base page.
Here's what I did:
------------------
1] Setup SimpleForum. I've defined Forum.GroupFooter to contain:
[[<<]]
(:commentboxchrono:)
------------------
2] Change your skin template to include a link to the Discussion forum.
I changed my skin to include a tabbed link to a 'discussion' forum page.
My skin .tmpl has:
<!--function:DisplayDiscuss-->
------------------
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);
}
function DisplayDiscuss($x) {
global $ScriptUrl;
$Group = FmtPageName('$Group',$x);
$Page = FmtPageName('$Name',$x);
if ($Group=='Forum') {
$BasePage = explode('-',$Page,2);
$html = "<a \n id='return'
href='$ScriptUrl/".$BasePage[0]."/".$BasePage[1]."'>return</a>\n";
} else {
$html = "<a \n id='discuss'
href='$ScriptUrl/Forum/$Group-$Page'>discuss
(".FindInPage("Forum/$Group-$Page",'>>messagehead<<').")</a>\n";
}
echo $html;
return;
};
That's it!
~ ~ Dave
More information about the pmwiki-users
mailing list