Jump to content

Create a new hook


Recommended Posts

Hi,

 

    This is my first message here. I use prestashop as a contentt builder but I have a theme where I need a new hook to can add from the administrator the blocks I need to appear on the public site. I'm on prestashop 1.5.5.

 

   I make some steeps but at least {HOOK_NEWHOOK} is always empty.

 

   1. First I make an insert on hook_alias table. Alias: NewHook. Name: displayNewHook.

 

   2. Make another insert on hook table. Name: displayNewHook.

 

   At this point, If I go to Module->Position displayNewHook appears there.

 

   3. On classes/controller/FrontController.php I add this line:

 

            

 'HOOK_NEWHOOK' => Hook::exec('displayNewHook'),

       after

        

    HOOK_TOP' => Hook::exec('displayTop'),

   4. I add {$HOOK_NEWHOOK} on themes/my_theme/footer.tpl.

 

   5. I add on modules/blocksnewslleter/blocksnewslleter.php, for example those lines:

 

  

public function hookNewHook($params)
    {
    return $this->hookRightColumn($params);
    }

  after

  public function hookDisplayLeftColumn($params)
    {
        $this->_prepareHook($params);
        return $this->display(__FILE__, 'blocknewsletter.tpl');
    }

  6. Insert the new hook between blockNewsletters module and New Hook hook on Module->Position

 

   I go to my home and where I put {$HOOK_NEWHOOK} on the footer.tpl is empty when I have newsletter module hooked and added to that hook.

 

   I read a lot of documentation and videotutorials but still {$HOOK_NEWHOOK} is empty. ¿What have I forgotten?

 

Thanks. Regards. aitiba

Link to comment
Share on other sites

Hi Nemo1,

 

        Your solution goes so well for all the modules that I need but I can put in my own hook "my account block" relathed information. This is what I do.

 

1. Put on my theme header {hook h='cortinilla'} and on position admin area appears this new hook.

 

2. On modules/blockmyaccount/blockmyaccount.php file on install() function I add 

|| !$this->registerHook('cortinilla'))

after

|| !$this->registerHook('actionModuleUnRegisterUnHookAfter')

3. On modules/blockmyaccount/blockmyaccount.php add to the final of the file

public function hookCortinilla($params) {
        return $this->hookDisplayHeader($params);
 }

4. Reset the module to can use the new configuration. When I do that the user account block is assigned to Cortinilla hook but is appear on the page.

 

I try with another hook of my account module: hookDisplayLeftColumn and hookDisplayFooter with the same result. ¿Any ideas?

 

Thanks. Regards. aitiba

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...