public static function getToltalByCategory($id_lang, $id_category, $limit_start, $limit, $where = '') { $result = array(); $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post_lang pl, ' . _DB_PREFIX_ . 'smart_blog_post p WHERE pl.id_lang=' . $id_lang . ' and p.active = 1 AND pl.id_smart_blog_post=p.id_smart_blog_post AND p.id_category = ' . $id_category; if ($where) { $sql .= ' AND ' . $where; } $sql .= ' ORDER BY p.id_smart_blog_post DESC LIMIT ' . $limit_start . ',' . $limit; if (!($posts = Db::getInstance()->executeS($sql))) { return false; } $i = 0; $BlogCategory = new BlogCategory(); foreach ($posts as $post) { $result[$i]['id_post'] = $post['id_smart_blog_post']; $result[$i]['viewed'] = $post['viewed']; $result[$i]['meta_title'] = $post['meta_title']; $result[$i]['meta_description'] = $post['meta_description']; $result[$i]['short_description'] = $post['short_description']; $result[$i]['content'] = $post['content']; $result[$i]['meta_keyword'] = $post['meta_keyword']; $result[$i]['id_category'] = $post['id_category']; $result[$i]['link_rewrite'] = $post['link_rewrite']; $result[$i]['cat_link_rewrite'] = $BlogCategory->getCatLinkRewrite($post['id_category']); $employee = new Employee($post['id_author']); $result[$i]['lastname'] = $employee->lastname; $result[$i]['firstname'] = $employee->firstname; if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post['id_smart_blog_post'] . '.jpg')) { $image = $post['id_smart_blog_post']; $result[$i]['post_img'] = $image; } else { $result[$i]['post_img'] = 'no'; } $result[$i]['created'] = $post['created']; $i++; } return $result; }
public static function SmartBlogSearchPost($keyword = NULL, $id_lang = NULL5) { if ($keyword == NULL) { return false; } if ($id_lang == NULL) { $id_lang = (int) Context::getContext()->language->id; } $keyword = pSQL($keyword); $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'smart_blog_post_lang pl, ' . _DB_PREFIX_ . 'smart_blog_post p WHERE pl.id_lang=' . pSQL($id_lang) . ' AND p.active = 1 AND pl.id_smart_blog_post=p.id_smart_blog_post AND (pl.meta_title LIKE \'%' . $keyword . '%\' OR pl.meta_keyword LIKE \'%' . $keyword . '%\' OR pl.meta_description LIKE \'%' . $keyword . '%\' OR pl.content LIKE \'%' . $keyword . '%\') ORDER BY p.id_smart_blog_post DESC'; if (!($posts = Db::getInstance()->executeS($sql))) { return false; } $BlogCategory = new BlogCategory(); $i = 0; $result = array(); foreach ($posts as $post) { $result[$i]['post_format'] = $post['post_type']; $result[$i]['id_post'] = $post['id_smart_blog_post']; $result[$i]['viewed'] = $post['viewed']; $result[$i]['is_featured'] = $post['is_featured']; $result[$i]['meta_title'] = $post['meta_title']; $result[$i]['short_description'] = $post['short_description']; $result[$i]['meta_description'] = $post['meta_description']; $result[$i]['content'] = $post['content']; $result[$i]['meta_keyword'] = $post['meta_keyword']; $result[$i]['id_category'] = $post['id_category']; $result[$i]['link_rewrite'] = $post['link_rewrite']; $result[$i]['cat_name'] = $BlogCategory->getCatName($post['id_category']); $result[$i]['cat_link_rewrite'] = $BlogCategory->getCatLinkRewrite($post['id_category']); $employee = new Employee($post['id_author']); $result[$i]['lastname'] = $employee->lastname; $result[$i]['firstname'] = $employee->firstname; if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $post['id_smart_blog_post'] . '.jpg')) { $image = $post['id_smart_blog_post']; $result[$i]['post_img'] = $image; } else { $result[$i]['post_img'] = 'no'; } $result[$i]['created'] = Smartblog::displayDate($post['created']); $i++; } return $result; }