Views
Wordpress as comment engine for Mediawiki
From Shadowfax
MediaWiki is great as a lightweight CMS, but there are some things that it doesn't do so well. Discussion tabs may be great in a wiki - but for discrete comments by non-logged in users they don't fare so well. fortunately adding a comment engine to MediaWiki is pretty straightforward.
I was going to make my own lightweight comment engine until I stumbled across Greg Perry's extension which allows Wordpress to be used as a comment engine for MediaWiki. Given that I was planning to use Wordpress as a blogging engine it seemed the ideal comment engine to use on this site (thanks Greg!). Greg's page which used to hold the code no longer exists and I have been unable to contact Greg, so I have taken the liberty of duplicating the MediaWiki Wordpress Comment Extension Code on this site.
I have also managed to obtain a copy of Greg's original code, which is presented on an as is basis. At some stage soon I hope to have a bit of time to clarify all this and add some decent usage notes to it.
In its initial form, however, there were a few minor issues with the approach - some of which I have fixed.
- You need to create a separate blog entry for each mediawiki page being commented on, otherwise the comments are shared with all pages being commented on
- It redirects the user to the wordpress page on comment completion
- It needs to be entered into each wiki page article.
- Error messages appear on a non-branded and rather empty page
- It assumed that the Wordpress was installed in the same database as MediaWiki
The following sections detail possible fixes to some of these items. I'm relatively new to both wordpress and mediawiki so I can't guarantee that these are the most efficient ways to apply the fixes, but they do work.
Contents |
One blog entry for all comments
To fix the first issue requires modifying the Wordpress database to add a field to a table and editing the Wordpress core. It is worth backing up the appropriate files before you make any changes - and I disclaim any responsibility if you break your wordpress installation. You have been warned!
With this mod in place only one blog entry is needed, but each wiki page has its own unique comment stream. Note that this only works if page names in the wiki are unique and less than 255 characters. Also note that moving/renaming a page will break the link to any existing comments.
From MySQL prompt
USE wordpress-database-name-here; ALTER TABLE wp_comments ADD wikipage varchar(255);
In wp_insert_comment (found in wordpress/include/comment.php
//add the following line if (!isset($comment_wikipage)) $comment_wikipage = ''; //And change the insert SQL to $result = $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id,wikipage) VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s)", $comment_post_ID, $comment_author, $comment_author_email, $comment_author_url, $comment_author_IP, $comment_date, $comment_date_gmt, $comment_content, $comment_approved, $comment_agent, $comment_type, $comment_parent, $user_id,$comment_wikipage) );
In wordpress/wp-comments-post.php
//Add the following line $comment_wikipage = ( isset($_POST['wikipage']) ) ? trim($_POST['wikipage']) : null; //And modify the $commentdata line to $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID', 'comment_wikipage');
Return the user to wiki page not wordpress
This is a very easy fix since wordpress already looks for a redirect parameter in the posted form. With this tweak in place the user is returned to the wiki page that they posted the comment from not redirected to the wordpress blog. I have already applied this fix in the code presented on this site
Add Comments form to all wiki pages by default
Again relatively straightforward. All you need to do is call get_wordpress_comments() from the mediawiki template file where you want the comments to appear. eg
<?php get_wordpress_comments(); ?>
Applying Styles to the comments
If you are using my version of this extension, you can apply styles to the comments using CSS - either in the main.css for the appropriate skin, or the wiki page MediaWiki:Common.css
The following example code show the elements that can be used. If you want the comment author name to occur on its own line, you can add display: block; to the comment-author section.
#comment-outer { text-align: center; } #comment-list { text-align: left; margin-left: auto; margin-right: auto; width: 85%; } .comment-item { margin-top: 4px; padding: 10px; border: 1pt solid #dedeee; background-color: #eef3f5; } .comment-inp { padding: 3px; border: 1pt solid #84b0c7; } .comment-author { border: 1pt solid #84b0c7; background-color: #d5e1e8; padding: 3px; }
Leave your comment
Comments
Nov 06 2011 1:11 am
I'm using Wordpress ver 3.2.1 Could you help me? Thanks!
Nov 05 2011 11:37 am
Apologies for late reply. I'm not sure I do know. It may be an issue with the style sheet of your wiki. Which version of the script are you using? Greg's 0.9.0 or my 0.10.0?
Jun 14 2011 11:21 pm
May 29 2011 9:16 am
Jan 23 2011 12:00 am
Oct 13 2009 8:02 am
Oct 13 2009 5:24 am
Jul 06 2009 11:35 pm
Jun 07 2009 9:10 am