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