Jump to content

[SOLVED] Need to add cms page on category page


Recommended Posts

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 by ahmed1136 (see edit history)
Link to comment
Share on other sites

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 by ahmed1136 (see edit history)
Link to comment
Share on other sites

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  :)

  • Like 2
Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...
×
×
  • Create New...