Extension talk:ArticleComments

Include discussion page on article page
Works great, but I am looking for a way to have comments appended to the article's own page on the bottom, much like Wordpress or any blogging software does. Main article, then the box to enter a comment, then a Comments header, followed by the comments themselves. Integration with reCAPTCHA would also be nice.

This extension is working very well, Im very impressed. Good support from Jim R Wilson also! Ive implemented a CSS for this at LeerWiki.nl regards B.Vahrmeijer


 * Regarding embedding the comments for an article into the article itself - there's really no need (in my mind) to do this programmatically. MediaWiki already has a mechanism for pulling to the contents of one article into another.  The code for the suggestion above would be:   This would show the comment form, followed by any contents from the talk page, transcluded into the regular article.  Hope this helps! -- Jimbojw 11:35, 12 July 2007 (UTC)

Require_once position
The line position for the ArticleComments "require" statement within LocalSettings.php made a difference between working and not working. This extension worked when I placed the ArticleComments "require" statement before other "require" and "include" statements. --Infonomics 22:31, 17 August 2007 (UTC)


 * Hi Infonomics. That's probably due to the other extensions, not ArticleComments.  It's a common mistake for an extension to fail to return a value for a hook implementation.  When this happens, the hook stack is killed and no further processing is done for that hook.  ArticleComments correctly returns true, giving other extensions a chance to run.  It's likely that the other extensions were killing the stack before ArticleComments could execute.  Thanks! -- Jimbojw 20:51, 20 August 2007 (UTC)

Code by default on all article pages
I really like this extension and works fine but: My wiki is already set up and I have 4500 articles which I want to include this extension on. I cannot add the code manually to each article and don't want to bother users to add it when they create a new article. So can it be included on each article and maybe category page BY DEFAULT?

Extension:TalkHere is displaying on all pages you define per namespace, but besides no ability to seperate the messages, a magic word like __NOTALKHERE__ is missing so if I find a way to add the code on all pages, __NOCOMMENTS__ would need to be possible (e.g. for Main Page) --Subfader 23:23, 21 August 2007 (UTC)
 * I've used the headerfooter extension top do this Tarlachmoorhouse 22:16, 14 December 2007 (UTC)
 * See below "Leave Comment" + all comments on all article pages --Subfader
 * Hmh but I cannot disable the footer which reads using __NONSFOOTER__ or __NOFOOTER__ --Subfader 12:50, 14 June 2008 (UTC)

Return to article page after submitting a comment
I want to integrate this with the code from above. But after submitting a comment the article page should reload instead of the You have successfully... You may view... page. On the Special:ProcessComment it should be possible to add a ReturnTo with a timeout. I saw this on other extensions, which takes you to the Main Page after 5 seconds: $wgOut->returnToMain; ? --Subfader 23:47, 21 August 2007 (UTC)

Latest posts on top
I'd like to see the order changed so that new comments are on top. This would also make sense when showing the comment form by default so the new post appears directly under the form. How's that possible? --Subfader 23:23, 21 August 2007 (UTC)

User Names
I'd like to remove the Name field and have the user name included like the format but catched like ~ signature does to avoid fake posting. This could easily be done on MediaWiki:Article-comments-new-comment i guess? --Subfader 23:23, 21 August 2007 (UTC)
 * still wanted. if logged in user, link name, if visitor, plain text ;) --Subfader 15:44, 12 April 2008 (UTC)

I belive the solution is to change this line: into: Frihet 13:58, 8 April 2009 (UTC)

Preview Button
A preview button next to the submit button would be cool cos the extension is made for people without a clue and aince it uses wiki formatting it forces unhappy surprises after posting a comment and such visitors won't see a way to edit it correctly. It would make even more sense when the Edit Toolbar was loaded. --Subfader 23:23, 21 August 2007 (UTC)

Latest Comments
How can I display a list of pages with new comments on? Something like and maybe even make parts of the comments display on that list just like searching in the Talk namespace does? I guess it's not possible cos you'd have to change includes/SpecialNewpages.php? What about creating a Special:Newcomments.php instead? --Subfader 23:15, 21 August 2007 (UTC)
 * See below "Leave Comment" + all comments on all article pages --Subfader

Special:ProcessComment
This is a good extension (more stable than beta IMHO), but the Special:ProcessComment special page at Special:Specialpages is annoying. This should fix it:

Basically, I changed one true to false in the SpecialPage::addPage function to make it an unlisted special page. -- Sayuri 13:38, 24 September 2007 (UTC)


 * Thanks Sayuri! You have a good point about not listing the special page, next time I revisit the code, I'll add that. Also, regarding "beta" status - thanks!  I take my released code very seriously, so if you find any other troubles, please let me know. -- Jimbojw 15:35, 24 September 2007 (UTC)

Captcha support
Other users here have already asked that ~ would be used instead of asking for a name. Thus one would know if a comment was written by a registered user or by an anonymous user. And speaking of anonymous users, Captcha support is reallly required for them. -79.183.105.239 15:16, 22 December 2007 (UTC)


 * I have considered integrating with the Captcha extension - just haven't gotten around to it yet. :/ --Jimbojw (talk | blog) 17:50, 18 March 2008 (UTC)


 * Captchas are the worst anti-spam solution if you want non-logged-in users to leave comments. You should use $wgSpamRegex and my SimpleAntiBot solution and check if this reduces spam after a few weeks of testing. --Subfader 23:30, 19 May 2009 (UTC)


 * I have patch that requires ReCAPTCHA answer for everyone who wants to leave a comment. Try it here and let me know if you are interested. -- Jaroslav Tulach, Jun 11, 2009

Customizable fields
Maybe somehow use a template for the fields? -79.183.105.239 15:16, 22 December 2007 (UTC)

No SPAM protection!
The spammers now shit on my site via comments. What can I do? Everything I have set up on $wgSpamRegex and Extension:SpamBlacklist is not affected by the comment process. I.e. I cannot enter bad words / domains by editing a talk page the normal way, but when I leave a comment everything is possible. Please fix asap. --Subfader 12:54, 16 March 2008 (UTC)


 * Version 0.4.2 now has support for $wgSpamRegex. I have not yet integrated with the SpamBlacklist extension.  --Jimbojw (talk | blog) 17:48, 18 March 2008 (UTC)


 * Thanks. Updated :) --Subfader 11:19, 29 March 2008 (UTC)


 * Same problems, could you please address a short note on how to make ArticleComments & $wgSpamRegex work together? --sylvain 11:19, 15 May 2008 (UTC)

Can this extension work with a captcha? i.e. we use reCaptcha on our site... --Dmb 09:31, 27 January 2009 (UTC)
 * Mind that captchas for comments are annoying if people post comments more frequently. --Subfader 02:32, 28 January 2009 (UTC)

Error Message
I just enabled this extension on my wiki, however when I attempt to leave a comment, I get the following error message:

Sorry, the article "Whatever" is not accepting comments at this time.

Anyone have an idea as to what the problem could be?
 * You didn't "allow" the namespace in LocalSettings.php. E.g.:

require_once('extensions/ArticleComments.php'); $wgArticleCommentsNSDisplayList = array(NS_MAIN, NS_TALK, NS_HELP, NS_HELP_TALK); --Subfader 11:13, 29 March 2008 (UTC)

"Leave Comment" + all comments on all article pages
I wrote a step by step guide to do so: User:Subfader/Article Comments. What it will do:

The following explains how to enable having the "Leave a comment" link per default at the bottom of all pages of the namespaces you define + how to display the left comments from the discussion page below the article.

All that per default without adding  or   code to each individual article.

This includes displaying the comments on your article discussion pages left before you installed this extension and displaying the "Leave a comment" link on maybe unrelated (like non exisiting) pages or pages you may better not want to have visitor comments on e.g. Main Page. Atm there is no way to diasable the form once you went through this. Disabling would require a Magic Word like __NOCOMMENTSHERE__. But it's still very useful if you already have hundreds of articles in your wiki...

Jimbojw: Use my text as you like. Thanks for this great extension and your help back then although you won't rememeber me ;) --Subfader 15:57, 30 March 2008 (UTC)


 * Update: You CAN disable it on certain pages see below but it requires setting each page name manually into core code. --Subfader 01:25, 16 March 2009 (UTC)

PHP Notice: Undefined index:
Leaving comments works fine, but I checked my error log: With every comment being left I get a "PHP Notice: Undefined index:" for each line in ArticleComments.php: E.g.: PHP Notice: Undefined index:  titleKey in /...root.../  Any idea? --Subfader 09:08, 5 April 2008 (UTC)

Easy delete single comment button
I'd like to see a simple [x] in the upper right of each comment so it's easy to delete a certain comment without editing the discussion page and grabbing throw the div codes (which is quite annoying. [x] should only show up to users per group definition. --Subfader 11:01, 15 May 2008 (UTC)

Redirect back to original page after comment submission
Someone asked for that feature and for me it works to add at the very end of function specialProcessComment after the lines $wgOut->setPageTitle(wfMsgForContent($ac.'submission-succeeded')); $wgOut->addWikiText(wfMsgForContent($ac.'submission-success', $title->getPrefixedText)); $wgOut->addWikiText(wfMsgForContent($ac.'submission-view-all', $talkTitle->getPrefixedText)); these two lines: global $wgServer, $wgScriptPath; $wgOut->redirect($wgServer.$wgScriptPath.'/index.php/'.$title->getPrefixedText);

and than one is redirected back to the page with the comment tag. Works for me on MW 1.11.1 Optimale 11:02, 10 July 2008 (UTC)


 * Thanks, without a page reload leaving a comment now feels like ajax :) --Subfader 16:11, 10 July 2008 (UTC)

Error
Whenever I go into topics with the tag in I get the error:

Notice: Undefined index: showurlfield in /home/alexmac/public_html/tutorials/extensions/ArticleComments.php on line 176

Notice: Undefined index: showurlfield in /home/alexmac/public_html/tutorials/extensions/ArticleComments.php on line 176

I have installed it as it said.


 * I also have it (mentioned above somewhere) but don't mind it anymore. --Subfader 14:02, 9 September 2008 (UTC)

Conditional Show hides ALL Comments
Hi there. I am using conditional show and maybe I am doing something wrong, but it's hiding ALL comments. I'd like for users who are not logged in to be able to see the previous comments (but not the form.)

Thanks.

Don't display on certain pages in allowed namespace
'''It only worked for me on localhost. I was not able to reproduce it on the server. If you have a solution, please post.''' To hide the form on a certain page in a namespace you allowed; change the following as for the example Main Page in ArticleComments.php to and if you used "my hack" to display the left comments on the article page itself change MonoBook.php: to To add more pages it should be enough to double the string on each e.g. && $wgTitle != 'Main Page' && $wgTitle != 'Some Article' --Subfader 16:15, 4 October 2008 (UTC)
 * Update: Works fine on server :) --Subfader 01:25, 16 March 2009 (UTC)

Comments in place
I've hacked this extension into posting comments just above the &lt;comments /&gt; tag (on whatever page the tag is on), and signing the comment with  ~  (i.e. not asking for the user's name, using IP address if not logged in). If anyone wants a diff, shoot me an email. &#x2014;alxndr&#x00a0; (t) 04:06, 15 September 2007 (UTC)

I've had a play with this and a couple of other extensions
I hope this is clear when I describe it if not I'll try to set up an externally accessible wiki as an example.

Our wiki is used by people with little or no IT skills so I liked the look of 'ArticleComments' Extension:ArticleComments as it would allow me to have a small web form on the article pages that allows users to post comments to the discussion page without using the wiki editing system.

However ArticleComments requires a tag to be added to pages that you want the form to appear on, not wanting to have to do this manually on each page, I solved this using an extension HeaderFooter Extension:Header_Footer that will add a standard header / footer to any page within a name space.

I also wanted the ability to add comments, be available only to people who have logged in, we display the following on each page if users are not logged in:-
 * Log In at the top of the page to add your own comments or suggestions about this topic for other staff to read on the 'Discussion' page.
 * (Use the Submit Feedback link on the left it you want to contact the policy officers)

To do this I used the extension ConditionalShow Extension:ConditionalShow so I have a template :-

* * Log In at the top of the page to add your own comments or suggestions about this topic for other staff to read on the 'Discussion' page. (Use the Submit Feedback link on the left it you want to contact the policy officers) * Log In at the top of the page to add your own comments or suggestions about this topic for other staff to read on the 'Discussion' page. (Use the Submit Feedback link on the left it you want to contact the policy officers)

So basically conditional show is used to decide what to display in the footer either the comments form or the login message, based on whether the user has logged in, HeaderFooter adds this as a footer to the relevant pages, and if it's the tag then the user gets the comments form. --Unsigned

Comment not added (+ Java script extension from User:Pannini/ArticleComments )
After i add a new comment and click on "show comments" the new Comment is not added only in the discussion page but not on the mainpage. Only if i save the page again.

Can somebody help me??

Thanks Jan

See http://www.mediawiki.org/wiki/Manual:Purge for purgin cache.

OK Thanks for the information. Now it works. I add this to localsettings.php $wgScript          = "$wgScriptPath/index.php"; $wgArticlePath     = "$wgScript/$1?action=purge";

I dont know if its so right but it works. Thanks again

SimpleAntiBot
If you allowed comments by non-logged-in users you may know those stupid comments left by bots telling you how great your website is or just leaving (mostly russian) website links. For the latter I was happy to see $wgSpamRegex working with this extension but you can only add new rules after the damage. Filter ".ru/" and you disable 50% of the spam (including the slash which I always received to the URL :) Usability-wise any other spam protection is better than using captchas for visitor comments, trust me. Anway, $wgSpamRegex is not enough? Here's a simple solution to stop bots spamming your wiki via comments. It uses the trick of Extension:SimpleAntiSpam (but there is no need to install it for this tweak). This extension is used by e.g. wikipedia but only affects real page edits. Since bots don't view your website in a browser but check the source code etc and try to fill all given fields, this works quite well:

Add a hidden input field to the comment form. It uses display:none so it's only hidden for humans watching a website but not for bots which will simply fill it with their crap text. The comment will only be processed if the hidden input is empty. If filled, the form will refuse the comment and return the same error message as if the comment itself was missing.

Edit ArticleComments.php and into $content below add: This adds the hidden div with a fake label "Hompage" and fake input field named "wpAuthorHomepage" in my case cos I disabled the real Homapge field by default. So i chose to use Homepage to be sure 99% of the bots would fill it. If you use the real "Homepage", rename it to e.g. E-Mail or sth. In function specialProcessComment add  as global: and replace with: The  above is not very elegant cos it returns the empty message error. On the other hand nobody would see it anyway assuming display:none works in the browser or is not disabled in another way. Then maybe a real warning should be returned (too lazy). Remove the display:none in the div style to test it yourself by filling the field like a bot would. You need to purge the page to see it. --Subfader 00:40, 16 March 2009 (UTC)
 * After 1 month in use I can say I clearly reduced spam comments. Of course still humans leave some "fghdfggfh" comments but you can't stop those this way :) --Subfader 11:22, 20 April 2009 (UTC)
 * Isn't it possible to do a check where the first line of the comment is read and you do a char to char comparison?
 * something like:
 * if (char1 == char3 && char2 == char4){delete comment} so that the atleast cant write fgfgfgfg AndiRay 13:48, 23 April 2009 (UTC)
 * Block comments with bad words using $wgSpamRegex --Subfader 15:39, 23 April 2009 (UTC)

LeaveComment statement on every page, with exeptions, and modified talk page
I wanted to have a "leave comment..." statement at the bottom of every site (except mainsites, like User:Subfader/Article Comments) and I wanted it to open a talkpage to each article (like the extension does by default). On the talkpage I wanted the "leave comment..." statement to stand at the top... beneath the comments should be displayed like 1 but the newest ontop.

just check out my changes User:AndiRay/Article Comments and thx for all the info you guys already posted ;)

AndiRay 08:16, 20 April 2009 (UTC)

Error on MW 1.6
I get this error on MW 1.6. Everithing seems to work but after I enter the text and submit it I get the error! Is it because of the upgrades? Have you added something that 1.6 does not support?

Add Cache
You should add a cache on the comment box using the ConfirmEdit. Sachein 21:35, 11 May 2009 (UTC)


 * Add Cache? Anyway, captchas are a very bad solution to stop spam IMO (usability-wise). --Subfader 23:22, 19 May 2009 (UTC)

Define which talk to post to?
Is it possible to post the on say the Main Page but have the comments directed to the talk page of a specific user instead of the Main Page talk? - Omniomi 17:38, 21 May 2009 (UTC)
 * Note: I only need the comment option will always go to the same location, so a hard coded option is fine. I just cannot figure out what to edit in the source. - Omniomi
 * Which User talk page should it go to? to the User page of the posting person or whos article it is? you should look at the code in ArticleComments.php at

$title = Title::newFromDBkey($titleKey); $title->mNamespace = $titleNS - ($titleNS % 2); $article = new Article($title); $talkTitle = Title::newFromDBkey($commenterName);//Orig. titleKey changed to current Username $talkTitle->mNamespace = 2 + 1 - ($titleNS % 2);//Orig. titleNS changed to User Namespace $talkArticle = new Article($talkTitle);
 * 1) Setup title and talkTitle object

Just try this out and tell me if that is what your looking for ^^ if not i will take a look at it again... It could be that this only worked on my site because of changes I made. User:AndiRay/Article Comments AndiRay 14:40, 2 June 2009 (UTC)

Leaving another comment as anonymous user
When you display the comments on the article + you're not logged in + leave a comment that is not the first comment = it will not show up (but it's there though). Oddwise it works when you're logged in. Anyone else noticed this? Is there a solution? --Subfader 01:18, 9 June 2009 (UTC)