Integrating comments, ratings and social bookmarking with RokDownloads

This tutorial is provided in good faith based on the copy of RokDownloads available at the time of writing.  Changes can made by the original author and are beyond our control rendering the following advice out of date.  Use at your own risk.

To integrate JXtended Comments with RokDownloads, you need to create a layout override of the file detail page.

To create a layout override for this page, copy the following file:

/components/com_rokdownloads/views/file/tmpl/default.php

to

/templates/your_template/html/com_rokdownloads/file/default.php

where your_template is the name of the directory for the default template you have set for your site.  Make any adjustments to this new file.  Never make changes to the original file as you risk loosing them when you upgrade this extension.

At the top of the file, insert the following marked PHP code:

defined('_JEXEC') or die('Restricted access');

// For JXtended Comments
JHtml::addIncludePath(JPATH_SITE.'/components/com_comments/helpers/html');
$menus      = &JSite::getMenu();
$menu       = $menus->getActive();
$context    = 'rokdownloads';
$url        = 'index.php?option=com_rokdownloads&view=file&id='.$this->file->id; 
$route      = $url.'&Itemid='.$menu->id.'&id='.RokdownloadsModelDownloadItem::getSlug($this->file); 
// End JXtended Comments

$counter = 0;
?>

At the end of the file, insert the following code:

<?php
// Display the social bookmarks.
echo JHtml::_('comments.share', $route, $this->file->name);

// Display the ratings.
echo JHtml::_('comments.rating', $context, $this->file->id, $url, $route, $this->file->name);

// Display the social bookmarks.
echo JHtml::_('comments.comments', $context, $this->file->id, $url, $route, $this->file->name);
?>

Ensure that this is outside the HTML div with the id of rokdownloads otherwise the styles will conflict.