Unleash the Full Potential of Your PrestaShop Store

Welcome to MyPresta.eu – Your reliable partner in the e-commerce world. Find innovative modules that will take your business to a new level.

Show category description on CMS page

Question:

Is it possible in Prestashop 1.7 in the CMS pages to display the category description on the category page? Somehow I can't find any info anywhere. Well I have some CMS pages and would like te show there description of category with products. For example i have category page "dresses" - this category has a description, but I can find a way of displaying it.



PrestaShop expert answer

Hello

This case requires custom development. It is necessary to alter prestashop core and this is the only one available method.
controllers/front/CmsController.php has this code:

'cms' => $this->cms,

replace it with:

'cms' => $this->replaceShortcode($this->cms),

and create function:

    public function replaceShortcode($contents){
        preg_match_all('/\[catdesc\:[(0-9)]+\]/i', $contents->content, $matches);
        foreach ($matches[0] as $index => $match)
        {
            $explode = explode(":", $match);
            $category = new Category($explode[1], $this->context->language->id);
            $contents->content = str_replace($match, $category->description, $contents->content);
        }
        return $contents;
    }

then, in your cms pages contents you will be able to use shortcode [catdesc:5]  - shortcode will display description of category with ID 5 (you can replace 5 with any other ID).

author Milosz Myszczuk

Answer prepared by Miłosz Myszczuk, PrestaShop expert and official PrestaShop community moderator. Read more about VEKIA.

Comments