Integrating comments, ratings and social bookmarking with other extensions

Comments has been built to be able to be integrated with other Joomla extensions.  The ease or difficulty with which this can happen depends on how well these third-party extensions have been designed.  For any supporting the Joomla layout override system, integration is as simple as overriding the appropriate layout.  For other extensions, it may mean directly modifying core code.  Exactly how this is achieved varies from extension to extension and the respective authors should be consulted for advice on which files require modification.  It is beyond the scope of JXtended support to be able to advise on exactly how this is done for extensions we do not support.  However, the following describes the principles by which you could integrate Comments with other Joomla extensions.

This tutorial applies to Comments version 1.2.0 or higher only.

Integrating Comments

The following code is required to display the comments module in a third-party extension.  Note that all variables need to be set according to the available information in the extension.

// Include the helper to display the social bookmarks.
JHtml::addIncludePath(JPATH_SITE.'/components/com_comments/helpers/html');

// Set the context. This is an identifier unique to the extension.
$context = 'magazine';

// Set the id of the content item.
$id = $article->id;

// Set the unique link without routing information.
$url = 'index.php?option=com_zine&view=article&id='.(int) $article->id;

// Set the link that will be SEF routed.
$route = $url.':'.$article->alias.'&Itemid='.$Itemid;

// Set the title of the content to be passed to bookmark sites.
$title = $article->title;

// Display the comments.
JHtml::_('comments.comments', $context, $id, $url, $route, $title);

Integrating Ratings

The following code is required to display the ratings module in a third-party extension.  Note that all variables need to be set according to the available information in the extension.

// Include the helper to display the social bookmarks.
JHtml::addIncludePath(JPATH_SITE.'/components/com_comments/helpers/html');
// Set the context. This is an identifier unique to the extension.
$context = 'magazine';

// Set the id of the content item.
$id = $article->id;

// Set the unique link without routing information.
$url = 'index.php?option=com_zine&view=article&id='.(int) $article->id;

// Set the link that will be SEF routed.
$route = $url.':'.$article->alias.'&Itemid='.$Itemid;

// Set the title of the content to be passed to bookmark sites.
$title = $article->title;

// Display the ratings.
JHtml::_('comments.rating', $context, $id, $url, $route, $title);

Integrating Social Bookmarks

The following code is required to display the social bookmark module in a third-party extension.  Note that the variables $route and $title need to be set according to the available information in the extension.

// Include the helper to display the social bookmarks.
JHtml::addIncludePath(JPATH_SITE.'/components/com_comments/helpers/html');

// Set the link to the content to be passed to bookmark sites.
$route = 'index.php?option=com_zine&view=article&id='.(int) $article->id;

// Set the title of the content to be passed to bookmark sites.
$title = $article->title;

// Display the social bookmarks.
JHtml::_('comments.share', $route, $title);