1. JonusC
  2. Newbies area
  3. Monday, 15 June 2009
  4.  Subscribe via email
Hello again.... :blush:

This one shows how many comments there are in total on the title bar. I think it's especially nice to have if you don't like the extended-info for the "Read More..." button. Here's a screenshot:

[img size=380]http://compojoom.com/components/com_agora/img/members/1866/jocomment_totalmod.png[/img]

Here's the code changes. On line 1860 of comment.class.php...
$html 		= str_replace('{_JOOMLACOMMENT_COMMENTS_TITLE}', _JOOMLACOMMENT_COMMENTS_TITLE, $this->_menu);

...comment that out with // and below that insert this code block...
/* Hack by JonusC - get the total number of comments */
$database =& JFactory::getDBO();
$com = $this->_component;
$query = "SELECT COUNT(*) FROM jos_comment WHERE contentid='$this->_content_id' AND component='$com' AND published='1'";
$database->SetQuery($query);
$number = $database->loadResult();
$html = str_replace('{_JOOMLACOMMENT_COMMENTS_TITLE}', _JOOMLACOMMENT_COMMENTS_TITLE." (".$number." total)", $this->_menu);

...thats it.

I don't know if that code is very good... i'm only new to this PHP language, but it shouldn't slow down the site much I hope...

Daniel, I also wanted to add a feature of showing "Oldest First" or "Newest First" in the Comment title, but for some reason the if ($this->_sort_downward) statement always returned false no matter what :blink: I have no idea why, could it be a bug or....... :unsure: here was the alternate code I was trying to use...
if ($this->_sort_downward) {
$html = str_replace('{_JOOMLACOMMENT_COMMENTS_TITLE}', _JOOMLACOMMENT_COMMENTS_TITLE." (".$number." total, newest first)", $this->_menu);
} else {
$html = str_replace('{_JOOMLACOMMENT_COMMENTS_TITLE}', _JOOMLACOMMENT_COMMENTS_TITLE." (".$number." total, oldest first)", $this->_menu);
}

...but it was always returning the 'oldest first' one, no matter what setting I had in Comments sorting. Is this because I have nested comments turned on?
Responses (2)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now

Last questions

CMigrator: Path from Drupal 6 to J5?
(Category s/b CMigrator, but didn't see it on the list) I'm interested in usi...
0 Replies
Posted on Monday, 28 April 2025
  • New
  • Dowload all Hotspots entries
    Hi there, I'm looking for a way to dowload all the Hotspots entries. I've got t...
    0 Replies
    Posted on Sunday, 06 April 2025
    • #kml
    • #download
    Set number of hotspots / user groups
    Hi, I'm working with Hotspots for my new website and I love it! After trying ...
    0 Replies
    Posted on Monday, 31 March 2025
    J5 compatibility for Hotspots
    Hi guys, Just started to update my old J3x website. Is there J5 compatibility p...
    1 Replies
    Posted on Monday, 24 February 2025
    • #Hotspots
    • #hotspots Joomla 5
    Text size in the comment input form
    Hello. How can I increase the font size in the comment input field? For examp...
    0 Replies
    Posted on Wednesday, 26 February 2025
    • #CComment 6