public function initContent() { parent::initContent(); $blogcomment = new Blogcomment(); $keyword = urldecode(pSQL(Tools::getValue('tag'))); $id_lang = (int) $this->context->language->id; $title_category = ''; $posts_per_page = Configuration::get('smartpostperpage'); $limit_start = 0; $limit = $posts_per_page; if ((bool) Tools::getValue('page')) { $c = (int) Tools::getValue('page'); $limit_start = $posts_per_page * ($c - 1); } $smartblogurlpattern = (int) Configuration::get('smartblogurlpattern'); //now we will check whihc option we need to url rewrite switch ($smartblogurlpattern) { case 1: $SmartBlog = new smartblog(); $keyword = urldecode(Tools::getValue('tag')); break; case 2: $keyword = urldecode(Tools::getValue('tag')); break; case 3: $keyword = urldecode(Tools::getValue('tag')); break; default: $keyword = urldecode(Tools::getValue('tag')); } $id_lang = (int) $this->context->language->id; $result = SmartBlogPost::tagsPost($keyword, $id_lang); $total = count($result); $totalpages = ceil($total / $posts_per_page); $i = 0; $to = array(); if (!empty($result)) { foreach ($result as $item) { $to[$i] = $blogcomment->getToltalComment($item['id_post']); $i++; } $j = 0; foreach ($to as $item) { if ($item == '') { $result[$j]['totalcomment'] = 0; } else { $result[$j]['totalcomment'] = $item; } $j++; } } $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content); $this->context->smarty->assign(array('keyword' => $keyword, 'postcategory' => $result, 'title_category' => 'ok working', 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages, 'smartbloglink' => $smartbloglink)); $template_name = 'tagresult.tpl'; $this->setTemplate($template_name); }
public function _posts() { $SmartBlogPost = new SmartBlogPost(); if (Tools::isSubmit('addComment')) { $id_lang = $this->context->language->id; $id_post = Tools::getValue('id_post'); $post = $SmartBlogPost->getPost($id_post, $id_lang); if ($post['comment_status'] == 1) { $blogcomment = new Blogcomment(); $name = Tools::getValue('name'); $comment = Tools::getValue('comment'); $mail = Tools::getValue('mail'); if (Tools::getValue('mail') == '') { $website = '#'; } else { $website = Tools::getValue('website'); } $id_parent_post = (int) Tools::getValue('id_parent_post'); if (empty($name)) { $this->_report .= '<p class="error">' . $this->module->l('Name is required') . '</p>'; } elseif (empty($comment)) { $this->_report .= '<p class="error">' . $this->module->l('Comment is required') . '</p>'; } elseif (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $this->_report .= '<p class="error">' . $this->module->l('E-mail is not valid') . '</p>'; } else { $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; if ($bc->add()) { $this->_report .= '<p class="success">' . $this->module->l('Comment added !') . '</p>'; Hook::exec('actionsbpostcomment', array('bc' => $bc)); $this->smartsendMail($name, $mail, $comment); } } } } }
public function initContent() { parent::initContent(); $rer = SmartBlogPost::tagsPost('asd'); $blogcomment = new Blogcomment(); $result = ''; $keyword = Tools::getValue('smartsearch'); Hook::exec('actionsbsearch', array('keyword' => Tools::getValue('smartsearch'))); $id_lang = (int) $this->context->language->id; $title_category = ''; $posts_per_page = Configuration::get('smartpostperpage'); $limit_start = 0; $limit = $posts_per_page; if ((bool) Tools::getValue('page')) { $c = (int) Tools::getValue('page'); $limit_start = $posts_per_page * ($c - 1); } $keyword = Tools::getValue('smartsearch'); $id_lang = (int) $this->context->language->id; $result = SmartBlogPost::SmartBlogSearchPost($keyword, $id_lang, $limit_start, $limit); $total = SmartBlogPost::SmartBlogSearchPostCount($keyword, $id_lang); $totalpages = ceil($total / $posts_per_page); $i = 0; if (!empty($result)) { foreach ($result as $item) { $to[$i] = $blogcomment->getToltalComment($item['id_post']); $i++; } $j = 0; foreach ($to as $item) { if ($item == '') { $result[$j]['totalcomment'] = 0; } else { $result[$j]['totalcomment'] = $item; } $j++; } } $this->context->smarty->assign(array('postcategory' => $result, 'title_category' => $title_category, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'post_per_page' => $posts_per_page, 'smartsearch' => Tools::getValue('smartsearch'), 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages)); $template_name = 'searchresult.tpl'; $this->setTemplate($template_name); }
public function initContent() { parent::initContent(); $blogcomment = new Blogcomment(); $year = Tools::getvalue('year'); $month = Tools::getvalue('month'); $title_category = ''; $posts_per_page = Configuration::get('smartpostperpage'); $limit_start = 0; $limit = $posts_per_page; if ((bool) Tools::getValue('page')) { $c = (int) Tools::getValue('page'); $limit_start = $posts_per_page * ($c - 1); } $result = SmartBlogPost::getArchiveResult($month, $year, $limit_start, $limit); $total = count($result); $totalpages = ceil($total / $posts_per_page); $i = 0; $to = array(); if (!empty($result)) { foreach ($result as $item) { $to[$i] = $blogcomment->getToltalComment($item['id_post']); $i++; } $j = 0; foreach ($to as $item) { if ($item == '') { $result[$j]['totalcomment'] = 0; } else { $result[$j]['totalcomment'] = $item; } $j++; } } $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content); $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'postcategory' => $result, 'title_category' => $title_category, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartshowviewed' => Configuration::get('smartshowviewed'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'totalpages' => $totalpages)); $template_name = 'archivecategory.tpl'; $this->setTemplate($template_name); }
public function hookLeftColumn($params) { if (Module::isInstalled('smartblog') != 1) { $this->smarty->assign(array('smartmodname' => $this->name)); return $this->display(__FILE__, 'views/templates/front/install_required.tpl'); } else { if (!$this->isCached('smartbloglatestcomments.tpl', $this->getCacheId())) { $id_lang = $this->context->language->id; $latesComments = Blogcomment::getLatestComments($id_lang); $this->smarty->assign(array('latesComments' => $latesComments)); } return $this->display(__FILE__, 'views/templates/front/smartbloglatestcomments.tpl', $this->getCacheId()); } }
function _posts() { $SmartBlogPost = new SmartBlogPost(); $SmartBlog = new SmartBlog(); $array_error = array(); $context = $id_lang = (int) Context::getContext()->language->id; $id_post = Tools::getValue('id_post'); $post = $SmartBlogPost->getPost($id_post, $id_lang); if ($post['comment_status'] == 1) { $blogcomment = new Blogcomment(); $name = Tools::getValue('name'); $comment = Tools::getValue('comment'); $mail = Tools::getValue('mail'); $captcha = Tools::getvalue('smartblogcaptcha'); $m_captcha = $_SESSION['ssmartblogcaptcha']; if (Tools::getValue('website') == '') { $website = '#'; } else { $website = Tools::getValue('website'); } $id_parent_post = (int) Tools::getValue('id_parent_post'); //'name'=>'Name between 2 - 25 characters !', if (empty($name)) { $array_error['name'] = $SmartBlog->l('Name is required'); } if (empty($comment)) { $array_error['comment'] = $SmartBlog->l('Comment must be between 25 and 1500 characters!'); } if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $array_error['mail'] = $SmartBlog->l('E-mail address not valid !'); } if (Configuration::get('smartcaptchaoption') == '1') { if ($captcha != $m_captcha) { $array_error['captcha'] = $SmartBlog->l('Captcha is not valid'); } } if (is_array($array_error) && count($array_error)) { $array_error['common'] = $SmartBlog->l('Warning: Please check required form bellow!'); die(Tools::jsonEncode(array('error' => $array_error))); } else { $array_success = array(); $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; $bc->created = Date('y-m-d H:i:s'); if ($bc->add()) { $array_success['common'] = $SmartBlog->l('Your comment successfully submitted.'); $array_success['success'] = $SmartBlog->l('Your comment successfully submitted'); Hook::exec('actionsbpostcomment', array('bc' => $bc)); die(Tools::jsonEncode($array_success)); } } } }
function _posts() { $SmartBlogPost = new SmartBlogPost(); $SmartBlog = new SmartBlog(); $array_error = array(); $id_lang = (int) Context::getContext()->language->id; $id_post = pSQL(Tools::getValue('id_post')); $post = $SmartBlogPost->getPost($id_post, $id_lang); $context = Context::getContext(); if ($post['comment_status'] == 1) { $name = pSQL(Tools::getValue('name')); $comment = pSQL(Tools::getValue('comment')); $mail = pSQL(Tools::getValue('mail')); $captcha = pSQL(Tools::getvalue('smartblogcaptcha')); $m_captcha = $context->cookie->__get('ssmartblogcaptcha'); if (Tools::getValue('website') == '') { $website = '#'; } else { $website = pSQL(Tools::getValue('website')); } $id_parent_post = (int) pSQL(Tools::getValue('id_parent_post')); //'name'=>'Name between 2 - 25 characters !', if (empty($name)) { $array_error['name'] = $SmartBlog->nrl; } if (empty($comment)) { $array_error['comment'] = $SmartBlog->crl; } if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $array_error['mail'] = $SmartBlog->erl; } if (Configuration::get('smartcaptchaoption') == '1') { if ($captcha != $m_captcha) { $array_error['captcha'] = $SmartBlog->capl; } } if (is_array($array_error) && count($array_error)) { $array_error['common'] = $SmartBlog->warl; die(Tools::jsonEncode(array('error' => $array_error))); } else { $array_success = array(); $comments = array(); $comments['name'] = $name; $comments['mail'] = $mail; $comments['comment'] = $comment; $comments['website'] = $website; if (!($id_parent_post = Tools::getvalue('comment_parent'))) { $id_parent_post = 0; } $value = Configuration::get('smartacceptcomment'); if (Configuration::get('smartacceptcomment') != '' && Configuration::get('smartacceptcomment') != null) { $value = Configuration::get('smartacceptcomment'); } else { $value = 0; } $bc = new Blogcomment(); $bc->id_post = (int) $id_post; $bc->name = $name; $bc->email = $mail; $bc->content = $comment; $bc->website = $website; $bc->id_parent = (int) $id_parent_post; $bc->active = (int) $value; $bc->created = Date('y-m-d H:i:s'); if ($bc->add()) { $array_success['common'] = $SmartBlog->sucl; $array_success['success'] = $SmartBlog->sucl; Hook::exec('actionsbpostcomment', array('bc' => $bc)); die(Tools::jsonEncode($array_success)); } } } }
<ul> <li><?php echo CHtml::link('Create New Post', array('blogpost/create')); ?> </li> <li><?php echo CHtml::link('Manage Posts', array('blogpost/admin')); ?> </li> <li><?php echo CHtml::link('Manage Comments', array('blogcomment/index')) . ' (' . Blogcomment::model()->pendingCommentCount . ')'; ?> </li> </ul>
public function view($id) { $this->data['title'] = "View Post"; $p = new Blogpost(); if ($p->exists($id)) { $p->get_where(array('id' => $id)); $this->data['post'] = $p; $this->data['title'] .= ' - ' . $p->title; $c = new Blogcomment(); $c->where('post_id = ' . $p->id); $this->data['commentcount'] = $c->count(); } else { $this->data['messages']['errors'][] = "No post by that id found."; } $this->load->view('post_view', $this->data); }
function content_5627a0e39aed71_45878629($_smarty_tpl) { if (!is_callable('smarty_modifier_date_format')) { include '/home/u481889647/public_html/tools/smarty/plugins/modifier.date_format.php'; } $_smarty_tpl->tpl_vars['option_tpl'] = new Smarty_variable(OvicLayoutControl::getTemplateFile('smartblog_latest_news.tpl', 'smartbloghomelatestnews'), null, 0); if ($_smarty_tpl->tpl_vars['option_tpl']->value !== null) { ?> <?php echo $_smarty_tpl->getSubTemplate($_smarty_tpl->tpl_vars['option_tpl']->value, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null, array(), 0); ?> <?php } else { ?> <div class="lg-margin2x hidden-sm hidden-xs"></div> <div class="md-margin2x visible-sm visible-xs"></div> <div class="carousel-container"> <h2 class="carousel-title"><?php echo smartyTranslate(array('s' => 'From the blog', 'mod' => 'smartbloghomelatestnews'), $_smarty_tpl); ?> </h2> <div class="row"> <?php if (isset($_smarty_tpl->tpl_vars['view_data']->value) && !empty($_smarty_tpl->tpl_vars['view_data']->value)) { ?> <div class="owl-carousel from-theblog-carousel from-theblog-wide"> <?php $_smarty_tpl->tpl_vars['i'] = new Smarty_variable(1, null, 0); ?> <?php $_smarty_tpl->tpl_vars['post'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['post']->_loop = false; $_from = $_smarty_tpl->tpl_vars['view_data']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['post']->key => $_smarty_tpl->tpl_vars['post']->value) { $_smarty_tpl->tpl_vars['post']->_loop = true; ?> <?php $_smarty_tpl->tpl_vars["options"] = new Smarty_variable(null, null, 0); ?> <?php $_smarty_tpl->createLocalArrayVariable('options', null, 0); $_smarty_tpl->tpl_vars['options']->value['id_post'] = $_smarty_tpl->tpl_vars['post']->value['id']; ?> <?php $_smarty_tpl->createLocalArrayVariable('options', null, 0); $_smarty_tpl->tpl_vars['options']->value['slug'] = $_smarty_tpl->tpl_vars['post']->value['link_rewrite']; ?> <article class="article"> <div class="article-media-container"><a href="<?php echo smartblog::GetSmartBlogLink('smartblog_post', $_smarty_tpl->tpl_vars['options']->value); ?> "><img src="<?php echo $_smarty_tpl->tpl_vars['modules_dir']->value; ?> smartblog/images/<?php echo $_smarty_tpl->tpl_vars['post']->value['post_img']; ?> -home-default.jpg" class="img-responsive" alt="<?php echo $_smarty_tpl->tpl_vars['post']->value['title']; ?> "></a></div> <div class="article-meta-box"><span class="article-icon article-date-icon"></span> <span class="meta-box-text"><?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['post']->value['date_added'], "%d %b"); ?> </span></div> <div class="article-meta-box article-meta-comments"><span class="article-icon article-comment-icon"></span> <a href="#" class="meta-box-text"><?php echo Blogcomment::getToltalComment($_smarty_tpl->tpl_vars['post']->value['id']); ?> <?php echo smartyTranslate(array('s' => 'Com', 'mod' => 'smartbloghomelatestnews'), $_smarty_tpl); ?> </a></div> <h3><a href="<?php echo smartblog::GetSmartBlogLink('smartblog_post', $_smarty_tpl->tpl_vars['options']->value); ?> "><?php echo $_smarty_tpl->tpl_vars['post']->value['title']; ?> </a></h3> <p><?php echo mb_convert_encoding(htmlspecialchars($_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate($_smarty_tpl->tpl_vars['post']->value['short_description'], 150, "..."), ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8'); ?> </p> <a href="<?php echo smartblog::GetSmartBlogLink('smartblog_post', $_smarty_tpl->tpl_vars['options']->value); ?> " class="readmore" role="button"><?php echo smartyTranslate(array('s' => 'Read More', 'mod' => 'smartbloghomelatestnews'), $_smarty_tpl); ?> </a> </article> <?php } ?> </div> <?php } ?> </div> </div> <?php } }
public function getRecentComments() { return Blogcomment::model()->findRecentComments($this->maxComments); }
public function initContent() { $category_status = ''; $totalpages = ''; $cat_image = 'no'; $categoryinfo = ''; $title_category = ''; $cat_link_rewrite = ''; $blogcomment = new Blogcomment(); $SmartBlogPost = new SmartBlogPost(); $BlogCategory = new BlogCategory(); $BlogPostCategory = new BlogPostCategory(); $smartblogurlpattern = (int) Configuration::get('smartblogurlpattern'); //now we will check whihc option we need to url rewrite switch ($smartblogurlpattern) { case 1: $SmartBlog = new smartblog(); $slug = Tools::getValue('slug'); $id_category = $SmartBlog->categoryslug2id($slug); break; case 2: $SmartBlog = new smartblog(); $id_category = Tools::getValue('id_category'); // if($id_category==''){ // $id_category = $SmartBlog->categoryslug2id($slug); // } break; default: $id_category = Tools::getValue('id_category'); } //$categoryinfo = $BlogCategory->getNameCategory($id_category); $posts_per_page = Configuration::get('smartpostperpage'); $limit_start = 0; $limit = $posts_per_page; if (!$id_category) { $total = (int) $SmartBlogPost->getToltal($this->context->language->id); } else { $total = (int) $SmartBlogPost->getToltalByCategory($this->context->language->id, $id_category); Hook::exec('actionsbcat', array('id_category' => pSQL(Tools::getvalue('id_category')))); } if ($total != '' || $total != 0) { $totalpages = ceil($total / $posts_per_page); } if ((bool) Tools::getValue('page')) { $c = (int) Tools::getValue('page'); $limit_start = $posts_per_page * ($c - 1); } if (!$id_category) { $allNews = $SmartBlogPost->getAllPost($this->context->language->id, $limit_start, $limit); } else { if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/category/' . $id_category . '.jpg')) { $cat_image = $id_category; } else { $cat_image = 'no'; } $categoryinfo = $BlogCategory->getNameCategory($id_category); $title_category = $categoryinfo[0]['name']; $category_status = $categoryinfo[0]['active']; $cat_link_rewrite = $categoryinfo[0]['link_rewrite']; if ($category_status == 1) { $allNews = $BlogPostCategory->getToltalByCategory($this->context->language->id, $id_category, $limit_start, $limit); } elseif ($category_status == 0) { $allNews = ''; } } $i = 0; $to = array(); if (!empty($allNews)) { foreach ($allNews as $item) { $to[$i] = $blogcomment->getToltalComment($item['id_post']); $i++; if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $item['id_post'] . '.jpg')) { $item['post_img'] = $item['id_post'] . '.jpg'; } else { $item['post_img'] = 'no'; } } $j = 0; foreach ($to as $item) { if ($item == '') { $allNews[$j]['totalcomment'] = 0; } else { $allNews[$j]['totalcomment'] = $item; } $j++; } } $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://'; $protocol_content = (isset($useSSL) and $useSSL and Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; $smartbloglink = new SmartBlogLink($protocol_link, $protocol_content); $i = 0; foreach ($allNews as $post) { $allNews[$i]['created'] = Smartblog::displayDate($post['created']); $i++; } parent::initContent(); $this->canonicalRedirection(); $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'postcategory' => $allNews, 'category_status' => $category_status, 'title_category' => $title_category, 'cat_link_rewrite' => $cat_link_rewrite, 'id_category' => $id_category, 'cat_image' => $cat_image, 'categoryinfo' => $categoryinfo, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartdisablecatimg' => Configuration::get('smartdisablecatimg'), 'smartshowviewed' => Configuration::get('smartshowviewed'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages)); $template_name = 'postcategory.tpl'; $this->setTemplate($template_name); }
public function initContent() { parent::initContent(); $category_status = ''; $totalpages = ''; $cat_image = 'no'; $categoryinfo = ''; $title_category = ''; $cat_link_rewrite = ''; $blogcomment = new Blogcomment(); $SmartBlogPost = new SmartBlogPost(); $BlogCategory = new BlogCategory(); $BlogPostCategory = new BlogPostCategory(); $id_category = Tools::getvalue('id_category'); $posts_per_page = Configuration::get('smartpostperpage'); $limit_start = 0; $limit = $posts_per_page; if (!($id_category = Tools::getvalue('id_category'))) { $total = $SmartBlogPost->getToltal($this->context->language->id); } else { $total = $SmartBlogPost->getToltalByCategory($this->context->language->id, $id_category); Hook::exec('actionsbcat', array('id_category' => Tools::getvalue('id_category'))); } if ($total != '' || $total != 0) { $totalpages = ceil($total / $posts_per_page); } if ((bool) Tools::getValue('page')) { $c = Tools::getValue('page'); $limit_start = $posts_per_page * ($c - 1); } if (!($id_category = Tools::getvalue('id_category'))) { $allNews = $SmartBlogPost->getAllPost($this->context->language->id, $limit_start, $limit); } else { if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/category/' . $id_category . '.jpg')) { $cat_image = $id_category; } else { $cat_image = 'no'; } $categoryinfo = $BlogCategory->getNameCategory($id_category); $title_category = $categoryinfo[0]['meta_title']; $category_status = $categoryinfo[0]['active']; $cat_link_rewrite = $categoryinfo[0]['link_rewrite']; if ($category_status == 1) { $allNews = $BlogPostCategory->getToltalByCategory($this->context->language->id, $id_category, $limit_start, $limit); } elseif ($category_status == 0) { $allNews = ''; } } $i = 0; if (!empty($allNews)) { foreach ($allNews as $item) { $to[$i] = $blogcomment->getToltalComment($item['id_post']); $i++; } $j = 0; foreach ($to as $item) { if ($item == '') { $allNews[$j]['totalcomment'] = 0; } else { $allNews[$j]['totalcomment'] = $item; } $j++; } } $this->context->smarty->assign(array('postcategory' => $allNews, 'category_status' => $category_status, 'title_category' => $title_category, 'cat_link_rewrite' => $cat_link_rewrite, 'id_category' => $id_category, 'cat_image' => $cat_image, 'categoryinfo' => $categoryinfo, 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'limit' => isset($limit) ? $limit : 0, 'limit_start' => isset($limit_start) ? $limit_start : 0, 'c' => isset($c) ? $c : 1, 'total' => $total, 'smartblogliststyle' => Configuration::get('smartblogliststyle'), 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'smartdisablecatimg' => Configuration::get('smartdisablecatimg'), 'smartshowviewed' => Configuration::get('smartshowviewed'), 'post_per_page' => $posts_per_page, 'pagenums' => $totalpages - 1, 'totalpages' => $totalpages)); $template_name = 'postcategory.tpl'; $this->setTemplate($template_name); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { //var_dump("loadModel"); if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Blogcomment::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }