0
votes

I'm rebuilding a Prestashop app and I would like to know, if it's possible to add a module which I bought (Home Categories Pro https://addons.prestashop.com/en/products-homepage/26563-home-products-pro.html) to a theme currently used on the page (SP Hurama). To be more clear, this module registers several hooks but, those are only used by the PS default bootstrap theme. Is there a way to use these hooks with the current theme? thanks.

1
If the new theme have the same hooks as default theme, yes, if not, of course not, and it is something that of course we could not know, I think you can try to install it and thus clear doubts. - Rolige
sorry, the theme uses different hooks then the default one. - belphegor1332

1 Answers

0
votes

There are two ways to implement your requirements.

The first, and recommended one, is to add a hook which module is using to your theme .tpl file to the right place(like in default-bootstrap for instance). It should be a line similar to

{hook h='displayYourHookName'}

or

{hook h='displayYourHookName' parameter=$parameter parameter_1=$parameter_1}

if it has any parameters.

The second way is to modify your module and add there desired hook which is already present in a theme. In the main module file yourmodulename.php add the following to the install method

public function install()
{
    return parent::install() &&
        $this->registerHook('displayYourHookName')
        // continue your module's code here
}

and implement the hook instantiation like

public function hookDisplayYourHookName($parameter = null, $parameter_1 = null)
{
    //your code here
    // parameters are necessary if you operate with some data, if not you can omit them
}

and then transplant a module to the hook or just reset it within admin panel.