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 - NULL

    after
    0_1521237706384_database after.png

    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:').' <>;=#{}',
                    ],
    

    0_1521239826130_95077859-8c87-4ac0-a0fb-5664aff233b6-grafik.png

    step 4
    if you want to see this field in your frontoffice categorys view - in your theme category.tpl
    add and change codes

    add 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}
    

    0_1521239890090_5ab926f4-866e-4b49-89db-51000c7990be-grafik.png


Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.