zimmer-media Posted March 16, 2018 Share Posted March 16, 2018 If you want a category short description above product list and category long description under product list. Example: step 1 - database add to "prefixcategorylang" catshortdescription - varchar(180) - utf8mb4unicodeci - yes - NULL after 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 codes add this under your tag ``` {$category->cat_short_description} at last move or change the full description under the pagination eg {if ($description)} {$category->description} {/if} ``` Link to comment Share on other sites More sharing options...
DarkHorse Posted September 13 Share Posted September 13 (edited) On 3/16/2018 at 5:38 PM, zimmer-media said: If you want a category short description above product list and category long description under product list. Example: step 1 - database add to "prefixcategorylang" catshortdescription - varchar(180) - utf8mb4unicodeci - yes - NULL after /assets/uploads/files/182/1521237716739database-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:').' <>;=#{}', ], /assets/uploads/files/182/152123983561295077859-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 tag ``` {$category->cat_short_description} at last move or change the full description under the pagination eg {if ($description)} {$category->description} {/if} ``` /assets/uploads/files/182/15212398997835ab926f4-866e-4b49-89db-51000c7990be-grafik.png I don't understand your approach... You are making structural changes to the data layer to accomplish a modification that should be manipulated in the presentation layer? If so, this is totally against any Client-Server or MVC architecture best practices that I am aware of. This type of modification should be performed within the theme (presentation or view layer) or the controller layer (and only those bits necessary to communicate between the two laters) as there is no need to modify the (information model or) database layer to accomplish this purpose. The appropriate changes to /themes/theme-name/product-list-item.tpl would accomplish this (using a custom theme or a child theme) and likely never cause an issue with future updates. Edited September 13 by DarkHorse Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now