|
Cookbook /
CommentsSplitSummary: A simple way to have publically-editable comments section at the bottom of your pages
Version:
Prerequisites:
Status:
Maintainer:
Categories: Comments
DescriptionThis is a simple way to have a publically-editable 'comments' section at the bottom of your pages The goal is to split pages in two, with the bottom half publically-editable, like this +------------------------------------------+ | the normal text of the page | | (which might not be publically editable) | +------------------------------------------+ | COMMENTS: | | and then a comments section | | (which is publically editable) | +------------------------------------------+ To achieve this, actually use two pages. The top half is as normal. The bottom half is in the Comments group. We'll adopt the following naming convention: Main/HomePage ... Comments/Main-HomePage Group/Name ... Comments/Group-Name Each top half will (:include:) its respective comments-page. You might, for instance, protect the top half so that only you can edit them. And leave the "Comments" half publically editable. Instructions1. Make the "Comments" group publically editable
2. Set up redirection
$pagename2 = preg_replace('/^Comments[\/\.](.*?)-(.*)$/','${1}/${2}',$pagename);
if ($action=='browse' && $pagename != $pagename2)
{ Redirect($pagename2); exit;
}
The idea is this: we don't really want anyone to be *looking* at the comments page on its own. We only want them to be looking at the main page, which includes its respective comments page. PmWiki by default has several places which take the user direct to the comments page. The user will go there after editing comments, for instance. And when clicking on a link in an RSS feed or on Site.AllRecentChanges. The redirection code here will trap all of these cases, and redirect all of them to the main page. 3. Include the commentsThe top half of our pages will include the following text.
----
[[Comments/{$Group}-{$Name}?action=edit|(edit)]]
(:include Comments/{$Group}-{$Name}:)
----
The question is, where does that text go? There are three scenarios:
$GroupFooterFmt =
'(:nl:)(:include $Group.GroupFooter:)'.
'(:nl:)---- [[Comments.{$Group}-{$Name}?action=edit|(edit)]](:nl:)'.
'(:include Comments.{$Group}-{$Name}:) (:nl:)----';
NotesAs always, if you have publically editable pages, you have to be careful of vandalism and link-spam. Some users of PmWiki suggest that just having a publically-knowable password is helpful! In Step (2) I actually set the password to "comment", and in Step (3) I tell people what the password is:
----
[[Comments/{$Group}-{$Name}?action=edit|(edit)]] [- (use the password "comments") -]
(:include Comments/{$Group}-{$Name}:)
----
Also, make sure to read UrlApprovals. Also, I personally use some powerful markup in my local/config.php
which lets me embed arbitrary html code. Anyone would also
be able to use the markup in the publically-editable contents area.
This could be a security risk: they could include malicious javascript,
for instance. Read the EnableHTML cookbook to see how CommentsNicer View of Comments using History Simonx, 18. April 2008
$GroupFooterFmt =
'(:nl:)(:include $Group.GroupFooter:)'.
'(:nl:)---- %target=_blank% [[Comments.{$Group}-{$Name}?action=edit|Write Comment...]](:nl:)'.
'%target=_blank% [[Comments.{$Group}-{$Name}?action=diff|Read Comments...]] (:nl:)----';
The Problem: This only creates a LINK to the History of the Discussion - where we want an inclusion (split)! However, History is not a wiki-page and neither can one use http-inclusion (e.g. cascaded sidebar). Any Idea? In case the actual wiki group name contains hyphens, like See AlsoContributorsLucian Wischik. Based on ideas by Hans and PM. |