Jump to content

Controller using hook


timmyraynor

Recommended Posts

I am trying to read through Developer Guide for PrestaShop 1.5, in the hand book it gives an example of using hook in the controller:

 

$this->context->smarty->assign('HOOK_LEFT_COLUMN', Module::hookExec('displayLeftColumn'));

 

but in what scenario we need to use the hook in the controller is not well explained, could anyone explain a example for me?

 

e.g. when using hook for modules, we could actually add page components.

then when using hook for controllers.....

 

Thanks

Link to comment
Share on other sites

Hi,

Not sure I understood your question.

In the example, you're assigning the hook's content to the hook_left_column variable. WHen you place the variable somewhere in the template, all hooks hooked there will be displayed.

 

If you only need to execute the hook (say, to perform an action)m you simply call hookExec :)

Link to comment
Share on other sites

well, the most important thing in this case: what you exctly want to achieve? please clarify it

That's my question too, this code is copied from the Prestashop 1.5 Developer Guide, I just want to know what is the purpose for doing such hookexec

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • 4 months later...

I think that timmyraynor want to create a function on his controller that can be hooked by one of the existing prestashop hooks.

 

Like we can do on modules, simply create a function "actionValidateOrder()", but  now on controllers instead a module.

Anyone succeed to do such a thing?

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...