Modifying the module to show comments for current page only

jbudd 04 Jun, 2009
It looks like I misunderstood the purpose of the chronocmments module. It shows the latest comments on all pages.

I would like to display the comments for the current page in a module.

I see that the component retrieves comments for the current page with this SELECT
$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('component')."' AND pageid= '".JRequest::getVar('pageid')."' AND parentid='0' AND published='1' AND verify='1' ORDER BY datetime ASC".$limit;


I tried to apply the test pageid = JRequest::getVar('pageid') in the chronocomments module like this
	$extra = " AND a.pageid= '" . JRequest::getVar('pageid') . "'";
		if($params->get( 'limitsections', '' ))$extra .= " AND b.sectionid IN (".$params->get( 'limitsections', '' ).")";
		if($params->get( 'limitcategories', '' ))$extra .= " AND b.catid IN (".$params->get( 'limitcategories', '' ).")";
		$query = "SELECT a.*, b.title AS articletitle FROM #__chrono_comments AS a, #__content AS b WHERE a.pageid = b.id AND a.published='1' AND a.verify='1'".$extra." ORDER BY a.datetime ".$params->get( 'order', 'ASC' )." LIMIT 0,".$params->get( 'commentscount', 5 );


But that causes the module to disappear - no error messages

Any ideas what I am doing wrong?
jbudd 04 Jun, 2009
Well the right syntax for the module seems to be:
$extra = " AND a.pageid= '" . JRequest::getVar('id') . "'";

around line 13 of helper.php.

To avoid the module vanishing on a page with no comments, I had to put something in the module header parameter.
This topic is locked and no more replies can be posted.