I'm writing my own module and the essential option is to control controller from the module options.
I know how to control tpl and js via module options but I can't get the way to control Prestashop controller from the module php file.
Simply I want to know the way how to do it.
I want to have four checkboxes with options to enable or disable module in four controllers like 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 this code display tpl file content in this four controllers in homepage (index), cms, category and the product pages. But how to put there some trigger to enable/disable values from the array?
Make a configuration field for the controllers:
This will appear in Modules > Modules > Configure (of your module). There are form helpers which can render PrestaShop forms, but this is simplified example showing that you will need aform that submits to the same page.
Controllers value for this example should be
index,category,cms,product
.Another way
Go to
Modules > Positions
Find your hook (for exampledisplayTop
) and your module, clickEdit
. Then selected the pages where you don't want to show the block.Generating Options Form
The correct way (but more complicated) would be to generate the form using
HelperForm
orHelperOptions
classes that come with PrestaShop