User:Subfader/Article Comments

Jump to navigation Jump to search

This explains a major tweak of Extension:ArticleComments I've set up myself and with the help of Jimbojw via IRC some while ago. It has been tested on MW 1.8.2 and all versions since 1.12.0.
Be sure to read Extension_talk:ArticleComments for updates on statements I left here about what is possible and what not.

"Leave Comment" + all comments on all article pages[edit]

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 <comments /> or <comments />{{:{{TALKSPACE}}:{{PAGENAME}}}} 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...

Update: Hiding the form and comments on certain pages of an allowed namespace is possible. See here.

Ok for you? Let's Go![edit]

Edit LocalSettings.php. Besides


you should add the following so it looks like this:

$wgArticleCommentsNSDisplayList = array(NS_MAIN, NS_TALK)

The second line removes the URL field from the comment form, remove the line if you want the field aynway.
The third line defines the namespaces this will take effect on; adjust to your needs, e.g. NS_MAIN, NS_TALK, NS_HELP, NS_HELP_TALK.

Edit skins/monobook.php and find

<!-- start content -->
<!-- end content -->

Add the following code inbetween or if you have content in that section already, add it to the very end.

<?php displayArticleCommentForm(); ?>
    global $wgTitle, $wgRequest;
    if ($wgTitle->getNamespace()==NS_MAIN &&
        (!$wgRequest->getVal('action') || $wgRequest->getVal('action')=='view')
    ) {
        $talkTitle = $wgTitle->getTalkPage();
        if ($talkTitle->exists()) {
            global $wgParser;
            $talkPage = new Article($talkTitle);
            $output = $wgParser->parse( $talkPage->getContent(), $talkTitle, $wgParser->mOptions );
            echo( "<h1>Comments</h1>\n" . $output->getText() );

<h1>Comments</h1>\n will add a new =Comment= headline after the first comment has been left; all coments below.
If you want to enable comments on more namespaces change the according line below global $wgTitle, $wgRequest; to something like: if(in_array($wgTitle->getNamespace(), array(NS_MAIN, NS_HELP))&&

At this point it already works, please test it now to understand the following. It still needs some modification to remove the second "Leave a comment" link and "Comments on ..." below the headline.

Edit extension/ArticleComments.php, find

# Initialize the talk page's content.
    if ( $talkContent == '' ) {
       $talkContent = wfMsgForContent($ac.'talk-page-starter', $title->getPrefixedText() );

Comment the second line out if you want to remove the complete section and get the comments listed below the headline right away. But it may also be a good way to leave a note for your visitors, since it will only be displayed after the first comment has been left, this cannot be instructions for what should be the content of the comments but something like "The comments below have been left by visitors or users. This site's operators cannot take responsibility for the content of the comments." To do so, don't comment this section out and change the content on MediaWiki:Article-comments-talk-page-starter to something like

<div class='commentstopmessage'>The comments below have been left by visitors or users. This site's operators cannot take responsibility for the content of the comments.</div>

. To style this line edit your MediaWiki:Commons.css and add something like this somewhere

div.commentstopmessage {
font: 90% verdana, arial, sans-serif;
color: grey;
text-align: center;
margin-top: -12px;
margin-bottom: 4px;

Latest Comments[edit]

This will list all talk pages with new comments of the Main namespace. Either go on Special:Newpages/namespace=Talk or create a page including this + some text you want to enter, e.g. create a page like "Project:Latest Comments", enter something like this:

==<center>This is a list of pages with new comments</center>==
<center><span style="color:#828282">Note that you're taken to the DISCUSSION page of the ARTICLE. The list only goes back a few days.</span></center>
{| width="100%" border="0" cellpadding="2" style="border-collapse:collapse; background:#ffa;"	 
<center>[http://yoursite/wiki/index.php?title=Special:Newpages&limit=50&offset=50&namespace=1 more]</center>

1 list is only possible for 1 namespace imo. For other namespaces change "Special:Newpages/namespace=Talk" and "&namespace=1" in the "more" link.

--Subfader 15:56, 30 March 2008 (UTC)