public function initContent() { $smartblogurlpattern = (int) Configuration::get('smartblogurlpattern'); //now we will check whihc option we need to url rewrite $id_post = null; switch ($smartblogurlpattern) { case 1: $SmartBlog = new smartblog(); $slug = Tools::getValue('slug'); $id_post = $SmartBlog->slug2id($slug); break; case 2: $id_post = pSQL(Tools::getvalue('id_post')); break; case 3: $id_post = pSQL(Tools::getvalue('id_post')); break; default: $id_post = pSQL(Tools::getvalue('id_post')); } if ($id_post) { $this->post = new SmartBlogPost($id_post, true, $this->context->language->id, $this->context->shop->id); } if (!Validate::isLoadedObject($this->post)) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('Post not found'); } parent::initContent(); $this->canonicalRedirection(); if (!$this->errors) { Hook::exec('actionsbsingle', array('id_post' => $this->post)); $blogcomment = new Blogcomment(); $SmartBlogPost = new SmartBlogPost(); $BlogCategory = new BlogCategory(); $id_lang = $this->context->language->id; $post = $SmartBlogPost->getPost($id_post, $id_lang); $title_category = array(); $getPostCategories = $this->getPostCategories($id_post); $i = 0; foreach ($getPostCategories as $category) { $title_category[] = $BlogCategory->getNameCategory($getPostCategories[$i]['id_smart_blog_category']); $i++; } $post['post_img'] = null; //--extra added $tags = $SmartBlogPost->getProductTags($id_post); $comment = $blogcomment->getComment($id_post); $countcomment = $blogcomment->getToltalComment($id_post); $id_cate = $post['id_category']; //$title_category = $BlogCategory->getNameCategory($id_cate); if (file_exists(_PS_MODULE_DIR_ . 'smartblog/images/' . $id_post . '.jpg')) { $post_img = $id_post . '.jpg'; } else { $post_img = 'no'; } $posts_previous = SmartBlogPost::getPreviousPostsById($id_lang, $id_post); $posts_next = SmartBlogPost::getNextPostsById($id_lang, $id_post); /* Server Params */ $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); SmartBlogPost::postViewed($id_post); //here we can give validation if category page or other page it will show $post['date'] = Smartblog::displayDate($post['created']); $this->context->smarty->assign(array('smartbloglink' => $smartbloglink, 'post' => $post, 'posts_next' => $posts_next, 'posts_previous' => $posts_previous, 'comments' => $comment, 'enableguestcomment' => Configuration::get('smartenableguestcomment'), 'is_looged' => $this->context->customer->isLogged(), 'is_looged_id' => $this->context->customer->id, 'is_looged_email' => $this->context->customer->email, 'is_looged_fname' => $this->context->customer->firstname, 'tags' => $tags, 'title_category' => $title_category, 'meta_title' => $post['meta_title'], 'post_active' => $post['active'], 'blogcontent' => $post['content'], 'id_post' => $post['id_post'], 'smartshowauthorstyle' => Configuration::get('smartshowauthorstyle'), 'smartshowauthor' => Configuration::get('smartshowauthor'), 'created' => Smartblog::displayDate($post['created']), 'firstname' => $post['firstname'], 'lastname' => $post['lastname'], 'smartcustomcss' => Configuration::get('smartcustomcss'), 'smartshownoimg' => Configuration::get('smartshownoimg'), 'comment_status' => $post['comment_status'], 'countcomment' => $countcomment, 'post_img' => $post_img, '_report' => $this->_report, 'id_category' => $post['id_category'])); $this->context->smarty->assign('HOOK_SMART_BLOG_POST_FOOTER', Hook::exec('displaySmartAfterPost')); } $this->setTemplate('posts.tpl'); }