ahmed1136 Posted November 6, 2013 Share Posted November 6, 2013 (edited) Hey every one i am stuck in code issue i wants to try to add cms page on my category page of prestashop under the products link in "CMS page should be here" section but i unable to show the cms page content and cms page id is 93 , can any one help me urgently i am waiting , Regards Edited November 29, 2013 by ahmed1136 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 6, 2013 Share Posted November 6, 2013 to category controller in init() function add code: $cms = new CMS(5); //5 is an id of cms page then attach this variable to smarty array. after all you will be able to use $cms variable in .tpl files Link to comment Share on other sites More sharing options...
ahmed1136 Posted November 6, 2013 Author Share Posted November 6, 2013 (edited) Can you write the full code here i am little bit confuse , i did add the code in int () public function init() { $cms = new CMS(93); // Get category ID $id_category = (int)Tools::getValue('id_category'); if (!$id_category || !Validate::isUnsignedId($id_category)) $this->errors[] = Tools::displayError('Missing category ID'); and on category.tpl i add this {$cms->content} regards Edited November 6, 2013 by ahmed1136 (see edit history) Link to comment Share on other sites More sharing options...
ahmed1136 Posted November 6, 2013 Author Share Posted November 6, 2013 So finally its done , for Prestashop 1.5 open /public_html/yourwebsite.com/controllers/front/CategoryController.php update this function public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'category.tpl'); if (!$this->customer_access) return; if (isset($this->context->cookie->id_compare)) $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare)); $this->productSort(); // Product sort must be called before assignProductList() $this->assignScenes(); $this->assignSubcategories(); if ($this->category->id != 1) $this->assignProductList();$cms = new CMS(93, $this->context->language->id); $this->context->smarty->assign(array( 'category' => $this->category, 'cms' => $cms, 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null, 'id_category' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers() )); } and then open /public_html/yourwebsite.com/themes/prestashop_theme/category.tpl and this where you like to display the cms page content <div class="rte{if $content_only} content_only{/if}">{$cms->content} </div> Thats all , i hope its will work for every one ,and By the way,vekia I really appreciate your support and thanks a lot.you save my day . Regards 2 Link to comment Share on other sites More sharing options...
vekia Posted November 6, 2013 Share Posted November 6, 2013 hello thank you for full code with smarty array variable included thread marked as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
Salus Posted April 11, 2014 Share Posted April 11, 2014 Very useful, thank you. Link to comment Share on other sites More sharing options...
Attrexx Posted August 4, 2015 Share Posted August 4, 2015 Great solution guys! Works fine on 1.6 but I wonder how do I target this CMS insert only to a certain category page :/ Link to comment Share on other sites More sharing options...
Recommended Posts