1

I want to display the article rating number in my template 'com_content/article' override. How can I get the value of rating_sum and rating_count of the opened article?

2

Please avoid pushing pure queries. Do it like this:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->
    select('rating_sum')->
    from('#__content_rating')->
    where('content_id='.(int)$this->item->id);
$db->setQuery($query) ;
$rating = $db->loadResult();

This will make your code more portable.

0

No problem found it

$db = JFactory::getDBO();
$id = $this->item->id;
$sql = 'SELECT rating_sum FROM #__content_rating WHERE content_id='.$id;
$db->setQuery($sql) ;
$rating = $db->loadResult();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.