官术网_书友最值得收藏!

Chapter 2. Hooks

A hook is the most essential concept to understand if you want to code a PrestaShop module, but as you will see, it's very easy.

Hooks are points on which you can attach modules in a way to change the normal behavior of the shop. In the PrestaShop 1.5/1.6 source code, their names are usually prefixed with display or action, depending on their purpose.

The display type hooks are generally used to add HTML or JS code on all or specific pages (for example, to add a block in a column, add an accessories link on a product page, add a field in a form, add information on a confirmation order page, and so on).

The action type hooks are used to change the behavior of the software by adding actions when events are triggered (for example, to add loyalty points to a customer when he or she places an order, logging modifications when a product is updated, send an e-mail to the merchant when a product is out of stock, and so on).

In this chapter, we will:

  • Register a module on a hook (to display comments form on the front office)
  • Use a database class (to register user comments in database)
  • Discover how hooks are triggered
  • Learn how to add new hooks
  • Learn how to use dynamic hooks
主站蜘蛛池模板: 饶平县| 吉林省| 塔河县| 扬州市| 公安县| 即墨市| 鞍山市| 龙里县| 施甸县| 丰顺县| 大悟县| 星子县| 澎湖县| 新竹县| 三河市| 四平市| 鹿泉市| 大化| 荆州市| 枞阳县| 开封县| 台江县| 墨玉县| 蒙自县| 宁远县| 房产| 牟定县| 福泉市| 马鞍山市| 尼木县| 福海县| 大宁县| 永嘉县| 宜宾市| 龙州县| 偃师市| 诏安县| 锡林郭勒盟| 晴隆县| 什邡市| 祁东县|