Child pages
  • Understanding and using hooks

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This article was written by Julien Breux, and published on May 5th, 2011 on the PrestaShop blog.

What is a

...

"hook"?

As you've probably noticed, PrestaShop is a software that allows you to create modules designed to interact directly with the heart of the solution’s display or events.

...

So there are actually two distinct types of "hooks".

  • Action "hooks" (letting you, for example, send out a mail when a client creates a user account)
  • View "hooks" (enabling you, for example, to display a module in a column)
Tip

Sometimes the view "hook" view can also serve as an action "hook." You do not need to do anything to display them. For example, you can make a recurring task on the homepage with the “home” "home hook".

If we take the example of the basic PrestaShop theme, on the home page, the solution uses "fixation points" as follows:

...

Next, it is important when installing your module to stick it to various “hooks” "hooks" desired. To do this, use the “registerHook” "registerHook" method, which also only accepts one parameter as well—the name of the hook.

...

Tip

There is no need to use the module's “uninstall” "uninstall" method to remove the "hook".

...

To create your own little personal "hook", you just simply save a row in the database table "ps_hook" with the name of your "hook”hook". (See 0 and 1 if it is compatible with LiveEdit or not)

...