CommentsSplit
Description
This 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.
Instructions
1. Make the "Comments" group publically editable
- Navigate to ...mywiki.../Comments/GroupAttributes?action=attr
- Set the edit password to
@nopass
2. Set up redirection
- Add the following to local/config.php
$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 comments
The 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:
- You might want comments only for one of your pages only. In this case, just edit the page as normal and put that text at the bottom.
- You might want comments for every page in a group, for instance the Main group. So, navigate to
Main/GroupFooter?action=edit
and put in the text above. If you want the comments to be printed, you'll also have to navigate toMain/GroupPrintFooter?action=edit
and put the text there as well. - You might want comments for every page on your site. In this case, go to local/config.php and put in the following. It will apply to every group. (and for printing, also set
$GroupPrintFooterFmt
$GroupFooterFmt = '(:nl:)(:include $Group.GroupFooter:)'. '(:nl:)---- [[Comments.{$Group}-{$Name}?action=edit|(edit)]](:nl:)'. '(:include Comments.{$Group}-{$Name}:) (:nl:)----';
Notes
As 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 $ROSPatterns
can be used to allow only people with "admin" privilages to embed html.
See Also
Contributors
Lucian Wischik. Based on ideas by Hans and PM.
Comments
See discussion at CommentsSplit-Talk