|
X-Comment<< X-Gallery | Cookbook-V1 | Comments >> Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
IntroductionX-Comment allows you to place a comment form any where on your WikiPage. Users can leave comments using the form (instead of editing the page in the usual way). Comments are appended to the bottom of the page, just below the comment form. Newest comments are listed last. GoalActually, the purpose of this add-on was to add commenting ability to my X-Gallery? script. I wanted a very slim, and light-weight method for users to leave comments, so I wrote this script.
Features
Download & Installation
UsageJust put the Customize ItThere are two parts you can customize, the comment form itself, and how the comments will be displayed. Customizing the Comment FormIf you can understand html, then you can probably customize this form pretty easily. Only thing to note is the use of some internal php variables contained in the $xCommentParams array. These are optional, you can hard-code what you like; reason I used variables here is for a future release that I'm working on that will take parameters from the user. For example, user might be able to specify [[x-comment: width=50]] to make a comment form with a width of 50 characters on the page. Other user-configurable variables might include bgcolor, height, and text labels.
$xCommentVars['form_template'] = "<table align=center
style='border:1px solid black; background-color:#FFC000;' width='100%'>
<form action='\$PageUrl' method='post'>
<tr>
<td class='x_comment' align='right'>Put your comments here</td>
<td><textarea name='text' rows='"
. $xCommentParams['height'] . "' cols='"
. $xCommentParams['width'] . "' wrap='"
. $xCommentParams['wrap'] . "'></textarea>
</td>
</tr>
<tr>
<td class='x_comment' align='right'>Sign your name here</td>
<td><input type='text' name='author' value='' size='32' />
<input type='submit' value=' Post ' />
<input type='reset' value='Reset' />
<input type='hidden' name='pagename' value='$PageName' />
<input type='hidden' name='action' value='post_x_comment' /></td>
</tr>
</form>
</table>";
Customizing the CommentYou can also customize the way the comments are output. I won't go in to any great detail about how to do this because I think the example below is pretty self-explanatory. The output uses basic PmWiki markup. $xCommentVars['comment_template'] = "\$Comment[[<<]] [+-\$Author+] [-(\$Date, \$Time)-] ---- [[x-comment:]]"; LimitationsYou can't use this form in your GroupHeader or GroupFooter because of the way it works. It looks for the <#>? directive so it knows where to start adding the next comment. Since the directive won't appear in the page itself (but in the Header/Footer), it won't be found, thus, the comment won't get added. I changed a bit of code (at line ~94) to make it possible: if (strpos ($text, "[[x-comment:]]") === false) { $text = $text."\n----\n".$comment."[[<<]]%gray%[-[=-".$author."-][-("=] ^ This should be: $text = $text."\n----\n".$comment."[[<<]]%gray%[-[=-".$author."-][-(=]" -- Christian Helft - June 30 2004 .$date.", ".$time.")-]%%"; } else { $text = preg_replace("/\\[\\[x-comment:(.*?)\\]\\]/", $template, $text); } If markup for X-Comment not found, add comment at end of page, otherwise proceed old way. Not the best implementation but an easy workaround for header/footer usage. Greetz Mazet Customization can only be done directly in the x-comment.php file. Setting the variables in config.php does not work. Also if an edit password has been set within PmWiki, you have to enter it before a comment could be added -- Klonk
See alsoThere is another comment/guestbook script available in the Cookbook. It's a bigger script, but it has more features, so if you are looking for something with more configuration options, you might give that a try. CopyrightScript written by Steven Leite. This script is release under the same terms and conditions as PmWiki (GNU GPL). pmwiki-2.2.0-beta68 -- Last modified by {{Ian MacGregor}}
|