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

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
主站蜘蛛池模板: 崇文区| 雷波县| 凤山市| 民县| 佳木斯市| 莫力| 顺昌县| 华宁县| 阿鲁科尔沁旗| 江源县| 绿春县| 昔阳县| 东明县| 西昌市| 中超| 云安县| 平遥县| 安仁县| 拜城县| 博兴县| 凤阳县| 博兴县| 浮山县| 安阳县| 浦县| 永仁县| 外汇| 高平市| 景宁| 霍城县| 蒲城县| 内江市| 色达县| 姚安县| 莱芜市| 乐平市| 庆元县| 巩留县| 精河县| 东乡族自治县| 达拉特旗|