Discussions
<< Black List | Cookbook-V1 | Switch To SSL Mode >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Question
How can I allow users to discuss a page without altering it?
Answer
You can make discussion pages for every page you have. Of course, this is awfully boring, so let's automate it.
Firstly, let's make the function that constructs and displays a link to the discussion page based on the current page's name:
function DiscussLink($pagename,$args) { # if the current page already ends in "-Discussion", don't make a link if (preg_match("/-Discussion$/",$pagename)) return ''; # otherwise, generate a link using FmtWikiLink print FmtWikiLink('',"{{".$pagename."-Discussion}}","Discuss"); }
This must be somewhere in your local/config.php. The preg_match line checks if the current page is already a discussion page (to avoid Main.HomePage-Discussion-Discussion-Discussion) and the last line construct a wiki link. Now the function must be referenced in the template:
<!--function:DiscussLink-->
If you use default template, this directive should be placed between the link to the edit page and the </td>
tag.
Contributors
If you change the previous function to:
function DiscussLink($pagename,$args) { # make a link back to the original page if (preg_match("/Discussion$/",$pagename)){ $posi = strpos( $pagename, "Discussion" ); $pagename = substr( $pagename, 0, $posi); print FmtWikiLink('',$pagename,$pagename); return ; } # otherwise, generate a link using FmtWikiLink print FmtWikiLink('',"{{".$pagename."Discussion}}","Discussion"); }
The function will put a link back to the page that is being discussed (the actual implementation just doesn't put anything).
Fly 5-Oct-2004 (I messed up with the date the first time :)
pmwiki-2.3.37 -- Last modified by {{}}?