hace 2 horas, 4you.software dijo:Hi.
You can add two conditions to the beginning of the code.
If you do not want to display the module in certain categories, you will create an array of categories, if you do not want to display the module on certain pages, you will create an array of pages.
For example, I don't want to display the module in categories 2 and 6.
Enter this part of the code:class PartsFilter extends Module { private $disabled_categories = array('2', '6'); public function __construct() { .....For example, I don't want the module to appear on the index pages and on the product detail page.
Enter this part of the code:class PartsFilter extends Module { private $disabled_pages = array('index', 'product'); public function __construct() { .....For both options, the code will be:
class PartsFilter extends Module { private $disabled_categories = array('2', '6'); private $disabled_pages = array('index', 'product'); public function __construct() { .....And now the most important part.
You will find a hook and add a condition until the end of the function.
For example, for hookDisplayTop, the code snippet will be:public function hookDisplayTop($params) { ... ... $page_name = Dispatcher::getInstance()->getController(); if (!in_array($page_name, $this->disabled_pages) && !in_array(Tools::getValue('id_category'), $this->disabled_categories)) { return $this->display(__FILE__, 'views/templates/front/filterbox_top.tpl'); } }
For example, for hookDisplayLeftColumn, the code snippet will be:
public function hookDisplayLeftColumn($params) { ... ... $page_name = Dispatcher::getInstance()->getController(); if (!in_array($page_name, $this->disabled_pages) && !in_array(Tools::getValue('id_category'), $this->disabled_categories)) { return $this->display(__FILE__, 'views/templates/front/filterbox.tpl'); } }
etc.
Thank you for your quick response. I do not know, if I am making a mistake when implementing the code, but it does not work for me, it is shown in all categories. I am attaching the code, so that you can verify if I am including it correctly.😓