The Coded One

programming, algorithms, discrete math, open-source

Using Disqus Plugin in Joomla

with 2 comments

Disqus Comment System is a plugin that provides seamless integration between Joomla and the popular commenting system Disqus.

Installing the plugin is pretty straightforward but there are a few gotcha’s.

Troubleshooting

No comments/links are showing up.

  • Check if the plugin is enabled.  (not enabled by default)
  • Open template/html/com_content/article/default.php and make sure that the following lines exist.
  • <?php echo $this->article->event->beforeDisplayContent; ?>
    ...
    <?php echo $this->article->event->afterDisplayContent; ?>
    

There is no Add New Comment section.

  • Verify your plugin setting.  The subdomain value should only be the name and not the entire URL. ie. mysite.disqus.com

Adding an Exclude List

Currently, there’s no setting for enabling/disabling comments per article so I did a few hacks.

plugins/content/jw_disqus.xml – Add this line before the </param> tag

<param name="disqus_excludelist" type="text" default="" label="Exclude list" description="Do no show comments for articles having these ids (comma separated)" />

plugins/content/jw_disqus.php – Create a new function that checks if the id of the article is in the exclude list.

/**
  * Check if the id of the current article is included in the excludelist parameter
  */
function isExcluded($article_id){
	$plugin =& JPluginHelper::getPlugin('content', 'jw_disqus');
	$pluginParams = new JParameter( $plugin->params );
	$disqus_excludelist = $pluginParams->def('disqus_excludelist','');
	if(in_array($article_id, explode(',', $disqus_excludelist))) {
	    return true;
	}
	return false;
}

Now simply return nothing in the callback functions if the article is in the exclude list.

/** just before content is output, returns output to be displayed */
function plgJWDisqus_onBeforeDisplayContent( &$row, &$params, $limitstart ){

    if(isExcluded($row->id)) {
	    return;
	}
...
/** just after content is output, returns output to be displayed */
function plgJWDisqus_onAfterDisplayContent( &$row, &$params, $limitstart ){

    if(isExcluded($row->id)) {
	    return;
	}
...

You should be all set after this.

Written by Mark Basmayor

April 27, 2009 at 10:55 pm

Posted in Joomla, PHP

Tagged with , , , ,

2 Responses

Subscribe to comments with RSS.

  1. Very insightful modification. I’m a newbie at php and can’t figure out how to modify your edit to exclude by category, which would be much more useful than article. Specifically, checking for the catid value in the array instead of the article id.

    Blake

    July 16, 2009 at 5:52 pm

  2. Got it. Simply substitute $row->id for $row->catid.

    Blake

    July 16, 2009 at 6:02 pm


Leave a Reply