php - How to disable module hooks for certain controllers in Prestashop? -
i'm writing own module , essential option control controller module options.
i know how control tpl , js via module options can't way control prestashop controller module php file.
simply want know way how it.
i want have 4 checkboxes options enable or disable module in 4 controllers index, cms, category, product.
i have right now:
$values = array('index','product','cms','category'); if(in_array(tools::getvalue('controller'), $values)){ return $this->display(__file__, 'mymodule.tpl'); }
and code display tpl file content in 4 controllers in homepage (index), cms, category , product pages. how put there trigger enable/disable values array?
make configuration field controllers:
public function getcontent() { if (tools::issubmit('my_controllers_list')) { configuration::updatevalue('my_controllers_list', (string)tools::getvalue('ps_my_controllers')); } $value = configuration::get('my_controllers_list'); return '<form action="" method="post"><input name="ps_my_controllers" value="'.$value.'"><input type="submit" value="save"></form>'; } public function hookdisplaytop() { $value = configuration::get('ps_my_controllers'); $controllers = explode(',', $value); if(in_array(tools::getvalue('controller'), $controllers)){ return $this->display(__file__, 'mymodule.tpl'); } return false; }
this appear in modules > modules > configure (of module). there form helpers can render prestashop forms, simplified example showing need aform submits same page.
controllers value example should index,category,cms,product
.
another way
go modules > positions
find hook (for example displaytop
) , module, click edit
. selected pages don't want show block.
generating options form
the correct way (but more complicated) generate form using helperform
or helperoptions
classes come prestashop
Comments
Post a Comment