Forums

Number of comments in article view ?

Lkark 12 Mar, 2009
Hi there๐Ÿ˜‰,

I just wonder how I get the number of comments in the article view (in the comment-form.html.php, to be precise).
Max_admin 13 Mar, 2009
Hi Lkark,

the code is available in plugins/content/chronocomments.php

you can just copy and paste, but here its:

$query = "SELECT * FROM #__chrono_comments WHERE component = '".JRequest::getVar('option')."' AND pageid= '".$pageid."' AND published='1' AND verify='1' ORDER BY datetime ASC";
				$database->setQuery( $query );
				$blogcomments = $database->loadObjectList();
echo count($blogcomments);


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Lkark 13 Mar, 2009
That ends up with and fatal error:


Fatal error: Call to a member function setQuery() on a non-object in public_html/components/com_chronocomments/templates/comment-form.html.php on line 7

And line # 7 in my case is:
$database->setQuery( $query );

Do you think you can solve that?๐Ÿ™‚
Max_admin 13 Mar, 2009
add this line at the top of the code:

$database =& JFactory::getDBO();
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Lkark 13 Mar, 2009
Thank you so much!๐Ÿ™‚

Btw, can I ask you if it's possible to load the latest comment's aritcle's id in the mod_chronocomments?
Max_admin 13 Mar, 2009
i think {pageid} will do this๐Ÿ˜‰

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Lkark 14 Mar, 2009
Oh, thanks, I must have missed that one :p. Thank you!๐Ÿ™‚
This topic is locked and no more replies can be posted.