JComments counter in category-view

More
12 years 5 months ago #31032 by ggppdk
It can have an small impact if you have 20+ items per page

to use SINGLE query for all items, try this (and correct if needed):
Code:
<?php $item_ids = array(); foreach ($items as $item) $item_ids[] = $item->id; $db =& JFactory::getDBO(); $query = 'SELECT COUNT(com.object_id) AS total, com.object_id AS item_id' . ' FROM #__jcomments AS com' . ' WHERE com.object_id in (' . implode(',',$item_ids) .')' . ' AND com.object_group = ' . $db->Quote('com_flexicontent') . ' AND com.published = 1' . ' GROUP BY com.object_id' ; $db->setQuery($query); $comments_count = $db->loadObjectList('item_id'); ?> <?php // AT --APPROPRIATE-- PLACE echo $comments_count[ $items[$i] ]->total ?>

I ll add this to category model and templates, as an option.


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.758 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save