How to add category short description
-
If you want a category short description above product list and category long description under product list.
Example:step 1 - database
add to "prefix_category_lang"
cat_short_description - varchar(180) - utf8mb4_unicode_ci - yes - NULLafter
step 2.1
modify the file “Category.php” from “/classes/Category.php”, preferably in the folder classes Override “/override/classes/Category.php” save
find the line/** @var string Description */ public $description;
add this
/** @var string Short Description */
public $cat_short_description;step 2.2
find the line'description' => ['type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'],
add this
'cat_short_description' => ['type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'],
step 3
change or copy your AdminCategoriesController.php from controllers / admin / to under override / controllers / admin / AdminCategoriesController.php
for example and find the code (depending on where this additional field should appear.)find the lines
'type' => 'categories', 'label' => $this->l('Parent category'), 'name' => 'id_parent', 'tree' => [ 'id' => 'categories-tree', 'selected_categories' => $selectedCategories, 'disabled_categories' => (!Tools::isSubmit('add'.$this->table) && !Tools::isSubmit('submitAdd'.$this->table)) ? [$this->_category->id] : null, 'root_category' => $context->shop->getCategory(), ], ],
an add
[ 'type' => 'textarea', 'label' => $this->l('Short Description'), 'name' => 'cat_short_description', 'autoload_rte' => true, 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', ],
step 4
if you want to see this field in your frontoffice categorys view - in your theme category.tpl
add and change codesadd this under your <h1> tag
<div id="category_description_full">{$category->cat_short_description}</div>
at last move or change the full description under the pagination
eg{if ($description)} <div id="category_description_full">{$category->description}</div> {/if}