News Show Pro G4 + K2 + Jcomments Hack

Free responsive Joomla 2.5 and 3.x module to present your content with easy and intuitive way.
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Tue May 03, 2011 9:12 am
Hello,

I've wrote a hack to get the comments count working in News Show Pro with Jcomments integreated to k2.

in /modules/mod_news_pro_gk4/gk_classes/gk.source.k2.php

replace this function
Code: Select all
function getComments($content, $config) {
      //
      $db =& JFactory::getDBO();
      $counters_tab = array();
      //
      if(count($content) > 0) {
         // initializing variables
         $sql_where = '';
         $ids = $content['ID'];
         //
         for($i = 0; $i < count($ids); $i++ ) {   
            // linking string with content IDs
            $sql_where .= ($i != 0) ? ' OR content.id = '.$ids[$i] : ' content.id = '.$ids[$i];
         }
         // creating SQL query
         $query_news = '
         SELECT
            content.id AS id,
            COUNT(comments.itemID) AS count         
         FROM
            #__k2_items AS content
            LEFT JOIN
               #__k2_comments AS comments
               ON comments.itemID = content.id       
         WHERE
            comments.published
            AND ( '.$sql_where.' )
         GROUP BY
            comments.itemID
         ;';
         // run SQL query
         $db->setQuery($query_news);
         // when exist some results
         if($counters = $db->loadObjectList()) {
            // generating tables of news data
            foreach($counters as $item) {                  
               $counters_tab['art'.$item->id] = $item->count;
            }
         }
      }
      
      return $counters_tab;
   }


with
Code: Select all
   function getComments($content, $config) {
      //
      $db =& JFactory::getDBO();
      $counters_tab = array();
            
      if(count($content) > 0) {
         // initializing variables
         $sql_where = '';
         $ids = $content['ID'];
         //
         for($i = 0; $i < count($ids); $i++ ) {   
            // linking string with content IDs
            $sql_where .= ($i != 0) ? ' OR content.id = '.$ids[$i] : ' content.id = '.$ids[$i];
         }
         // creating SQL query
         $query_news = '
         SELECT
            content.id AS id
         FROM
            #__k2_items AS content
         WHERE
            ( '.$sql_where.' )
         ;';
         // run SQL query
         $db->setQuery($query_news);
         // when exist some results
         if($counters = $db->loadObjectList()) {
         
            $comments = JPATH_BASE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';         
            // generating tables of news data
            if (file_exists($comments)) {
               require_once($comments);                              
               foreach($counters as $item) {      
               
                  $item->count = JComments::getCommentsCount($item->id, 'com_k2');
                  $counters_tab['art'.$item->id] = $item->count;
               }
            }
            
            else {            
               foreach($counters as $item) {      
                  $counters_tab['art'.$item->id] = 0;
               }                        
            }
               
         }
      }
            
      return $counters_tab;
   }   


tested with K2.4.1 + Jcomments 2.2 + K2 Jcomments plugin + News Show Pro g4
User avatar
Fresh Boarder

GK User
Thu May 05, 2011 11:47 pm
Excelent

Must be a add on in the main module update

Thanks man
User avatar
Fresh Boarder

teitbite
Sat May 07, 2011 2:53 pm
Hi

Thanks for that :) I'll be sure to show this post to our developers.
User avatar
Moderator

GK User
Sun Jul 03, 2011 11:34 am
Sounds great, but the hack and also the recently released News Show Pro GK4 3.0.0 with support for JComments comments count in K2 JComments plugin doesn't work at all :dry:

Why??

Used versions:
J!1.5.23
K2 2.4.1
Jcomments 2.2.0.2
K2 Jcomments plugin 1.1
News Show Pro GK4 3.0.0
User avatar
Fresh Boarder

teitbite
Mon Jul 04, 2011 1:13 pm
Hi

Can You please explan it a little better ? I'm having JComments plugin, new NSP an K2 working fine.
User avatar
Moderator

GK User
Mon Jul 04, 2011 3:58 pm
Hi teitbite,

News Show Pro GK4 3.0.0 doesn't count the K2 items with Jcomments...?
That should be one of the new features in NSP GK4 3.0.0. The comments count remains 'zero'.

regards,
GenesisFan
User avatar
Fresh Boarder

teitbite
Tue Jul 05, 2011 5:23 am
Hi

I'll forward this to programmers.
User avatar
Moderator


cron