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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -