Ejemplo n.º 1
0
 public static function getLatestComments($id_lang = null)
 {
     $result = array();
     if ($id_lang == null) {
         $id_lang = (int) Context::getContext()->language->id;
     }
     if (Configuration::get('smartshowhomecomments') != '' && Configuration::get('smartshowhomecomments') != null) {
         $limit = Configuration::get('smartshowhomecomments');
     } else {
         $limit = 5;
     }
     $sql = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_comment bc INNER JOIN 
             ' . _DB_PREFIX_ . 'smart_blog_post_shop bps ON bc.id_post=bps.id_smart_blog_post and bps.id_shop = ' . (int) Context::getContext()->shop->id . '
             WHERE  bc.active= 1 ORDER BY bc.id_smart_blog_comment DESC limit 0, ' . $limit);
     $i = 0;
     foreach ($sql as $post) {
         $result[$i]['id_smart_blog_comment'] = $post['id_smart_blog_comment'];
         $result[$i]['id_parent'] = $post['id_parent'];
         $result[$i]['id_customer'] = $post['id_customer'];
         $result[$i]['id_post'] = $post['id_post'];
         $result[$i]['name'] = $post['name'];
         $result[$i]['email'] = $post['email'];
         $result[$i]['website'] = $post['website'];
         $result[$i]['active'] = $post['active'];
         $result[$i]['created'] = $post['created'];
         $result[$i]['content'] = $post['content'];
         $SmartBlogPost = new SmartBlogPost();
         $result[$i]['slug'] = $SmartBlogPost->GetPostSlugById($post['id_post']);
         $i++;
     }
     return $result;
 }