hi,
I've got a question, in blog view (Section / Category listing), how can I retrieve the
number of comments available in a article item ?
I want to do something like:
Written by Author in 10/12/2008 | Comments ( XX )
Where XX is the number of comments in the current article.
Thanks for your atention!
I've got a question, in blog view (Section / Category listing), how can I retrieve the
number of comments available in a article item ?
I want to do something like:
Written by Author in 10/12/2008 | Comments ( XX )
Where XX is the number of comments in the current article.
Thanks for your atention!
Hi heldrida,
if you want to change the text of the current link then you can do this in the language file, is this what you need ?
Max
if you want to change the text of the current link then you can do this in the language file, is this what you need ?
Max
hi,
thanks for your atention.
No. What I need is diferent. I would like to, get the number of comments for that particular article, listed in blog view. I mean
when its displaying items by Section or by Category.
In joomla I can easily retrieve the Author name, and when it was created, etc. But how to get the number of available comments?
Is that easy?
I want to put that, in the Blog view, like
Written by AUTHOR_NAME on DATE_WHEN_WAS_CREATED | Comments ( NUMBER_OF_COMMENTS )
Being, AUTHOR_NAME already solved;
DATE_WHEN_WAS_CREATED already solved;
NUMBER_OF_COMMENTS dont know how to get that.
Thanks
thanks for your atention.
No. What I need is diferent. I would like to, get the number of comments for that particular article, listed in blog view. I mean
when its displaying items by Section or by Category.
In joomla I can easily retrieve the Author name, and when it was created, etc. But how to get the number of available comments?
Is that easy?
I want to put that, in the Blog view, like
Written by AUTHOR_NAME on DATE_WHEN_WAS_CREATED | Comments ( NUMBER_OF_COMMENTS )
Being, AUTHOR_NAME already solved;
DATE_WHEN_WAS_CREATED already solved;
NUMBER_OF_COMMENTS dont know how to get that.
Thanks
Hi, did you enable the "view number of comments in blog view" setting in comments parameters ?
regards
Max
regards
Max
hey😉
Yeah, thats a way to have it working, but, I've done a lot of costumization and a little scripting on my templates,
so showing number of comments work a lil bit diferently from what I want🙂
So, imagining it doesnt existe (the show number of comments in blog view)
Is there a way to grab/get the number of comments? a command ?
Thanks
Yeah, thats a way to have it working, but, I've done a lot of costumization and a little scripting on my templates,
so showing number of comments work a lil bit diferently from what I want🙂
So, imagining it doesnt existe (the show number of comments in blog view)
Is there a way to grab/get the number of comments? a command ?
Thanks
ok, try to check plugins/content/chronocomments.php then, it has the necessary code, its not 1 line but easy to get!
Regards
Max
Regards
Max
Hi,
thanks for your sugestion, but I didnt understood how to use it,
so I made a simple script for that:
thanks for your sugestion, but I didnt understood how to use it,
so I made a simple script for that:
<!--Begin Nr of Comments -->
<!-- <a> Start/begin, link to article with chrono comments -->
<?php echo '<a class="readOnDica" href="'.JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catslug, $this->item->sectionid)).'">'; ?>
<?php
<!-- Get article id -->
$articleid = $this->item->id;
<!--Get needed info from the database tables jos-chrono_comments and jos_content -->
$query = mysql_query("SELECT count( `jos_chrono_comments`.`pageid` ) , `jos_content`.`id`
FROM `jos_chrono_comments` , `jos_content`
WHERE `jos_chrono_comments`.`pageid` = `jos_content`.`id`
AND
`jos_content`.`id` = '".$articleid."'
GROUP BY `jos_content`.`id`;");
<!-- count number of comments available and apply value to variable -->
$nrComments = count(`pageid`);
<!-- if any result available in the query give nr comments (X) -->
if($row = mysql_fetch_array($query)){
echo "Comments (".$row[$nrComments].")";
}
<!--If theres no result in the query then give zero comments -->
else {
echo "Comments (0)";
}
?>
<!-- <a> Start/begin, link to article with chrono comments -->
<?php echo "</a>"; ?>
<!-- End Nr of Comments -->In case someone else is needing this, fell free to use it!
Thanks for sharing this🙂
regards
Max
regards
Max
Hi helrida,
I think the html comments you added may stop this script from working correctly. Here's an amended version for other readers who want to try the script.
Bob
>[/code]
I think the html comments you added may stop this script from working correctly. Here's an amended version for other readers who want to try the script.
<?php
// Begin Nr of Comments
// Start/begin, link to article with chrono comments
echo '<a class="readOnDica" href="'.JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catslug, $this->item->sectionid)).'">';
// Get article ID
$articleid = $this->item->id;
// Get needed info from the database tables jos-chrono_comments and jos_content
$db =& JFactory::getDBO();
$query = "
SELECT count( `jos_chrono_comments`.`pageid` ) , `jos_content`.`id`
FROM `jos_chrono_comments` , `jos_content`
WHERE `jos_chrono_comments`.`pageid` = `jos_content`.`id`
AND `jos_content`.`id` = '".$articleid."'
GROUP BY `jos_content`.`id`;";
$db-> setQuery($query);
// count number of comments available and apply value to variable
$nrComments = count(`pageid`);
if ( $row = $db->loadAssoc($query) ) {
// if any result available in the query give nr comments (X)
echo "Comments (".$row[$nrComments].")";
} else {
// If there's no result in the query then give zero comments -->
echo "Comments (0)";
}
// Close link to nr of Comments
echo "</a>";
// -- End Nr of Comments --
?>NB I've also changed over to Joomla DB code. Not tested and may need de-bugging.Bob
>[/code]
Thanks for your atention people!
I'm allways learning Grey =) Nice sugestion
Chrono Comments, has lots of potential! Really
loving it =)
- I've got another questions, I guess its better, to
open a new thread. Its about Displaying the comments
after DisplayContent, I mean, I want to keep the
signature of the article just after its text/content;
and then, I would like to have comments.
right now, I've got chrono, being displayed just after
the text/content of the article.
When I refear to DisplayContent, I mean:
$this->article->event->afterDisplayContent;
Here's the thread (for future readers, its allways best to open a new thread right?):
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=11889
I'm allways learning Grey =) Nice sugestion
Chrono Comments, has lots of potential! Really
loving it =)
- I've got another questions, I guess its better, to
open a new thread. Its about Displaying the comments
after DisplayContent, I mean, I want to keep the
signature of the article just after its text/content;
and then, I would like to have comments.
right now, I've got chrono, being displayed just after
the text/content of the article.
When I refear to DisplayContent, I mean:
$this->article->event->afterDisplayContent;
Here's the thread (for future readers, its allways best to open a new thread right?):
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=11889
Hi,
Nice script, I just can't get it to quite work when inserted into com_content/section/blog_item.php.
It's not returning the number of comments, I just get comments().
It is detecting empty articles as it should, they return comments(0).
My code has pretty well just been cut and paste from the script above..
[attachment=0]comment.gif[/attachment]
Just running on localhost via WAMP at the moment. Any help would be great.
Kind regards,
Matt
Nice script, I just can't get it to quite work when inserted into com_content/section/blog_item.php.
It's not returning the number of comments, I just get comments().
It is detecting empty articles as it should, they return comments(0).
My code has pretty well just been cut and paste from the script above..
<?php
// Begin Nr of Comments
// Start/begin, link to article with chrono comments
echo '<a class="readOnDica" href="'.JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catslug, $this->item->sectionid)).'">';
// Get article ID
$articleid = $this->item->id;
// Get needed info from the database tables jos-chrono_comments and jos_content
$db =& JFactory::getDBO();
$query = "
SELECT count( `jos_chrono_comments`.`pageid` ) , `jos_content`.`id`
FROM `jos_chrono_comments` , `jos_content`
WHERE `jos_chrono_comments`.`pageid` = `jos_content`.`id`
AND `jos_content`.`id` = '".$articleid."'
GROUP BY `jos_content`.`id`;";
$db-> setQuery($query);
// count number of comments available and apply value to variable
$nrComments = count(`pageid`);
if ( $row = $db->loadAssoc($query) ) {
// if any result available in the query give nr comments (X)
echo "Comments (".$row[$nrComments].")";
} else {
// If there's no result in the query then give zero comments -->
echo "Comments (0)";
}
// Close link to nr of Comments
echo "</a>";
// -- End Nr of Comments --
?>
<?php } ?>
[attachment=0]comment.gif[/attachment]
Just running on localhost via WAMP at the moment. Any help would be great.
Kind regards,
Matt
Hi samatt,
I'm not familiar with the ChronoComments code but his line looks wrong to me
Bob
I'm not familiar with the ChronoComments code but his line looks wrong to me
echo "Comments (".$row[$nrComments].")";I think that $row should be an array with two entries $row[?] and $row['id'] - I don't know what the index for the COUNT entry would be, I suggest that you echo $row out and take a look. Bob
This solved my problem:
change this line:
to this:
change this line:
echo "Comments (".$row[$nrComments].")";to this:
echo "Comments (".$row["count( `jos_chrono_comments`.`pageid` )"].")";
A suggestion in general when using the COUNT() (or other) function in queries, give the column an alias, and use that alias to index your result:
/Fredrik
...SELECT count( `jos_chrono_comments`.`pageid` ) AS comments,
...
echo "Comments (" . $row['comments'] . ")";
.../Fredrik
hi,
im just a newbie at this, so where exactly must i write this in?
best regards,
theo
im just a newbie at this, so where exactly must i write this in?
best regards,
theo
I'm a newb and I appreciate everyone's responses. Thanks especially to /Fredrik --> you saved me quite a bit of time!
Forgive this poor newbie's inexperience (I prefer that to naivety!). I can appreciate the coding for showing specific author comment counts but where is this best put to use. I mean...what benefit does it provide when compared to the comment count already available?
This topic is locked and no more replies can be posted.
