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

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
主站蜘蛛池模板: 苗栗县| 黎川县| 交城县| SHOW| 金华市| 定边县| 凌源市| 东阳市| 建平县| 襄垣县| 安国市| 嘉荫县| 沽源县| 宁蒗| 永年县| 视频| 江西省| 南陵县| 闵行区| 台前县| 卓资县| 洮南市| 临猗县| 游戏| 三门峡市| 连江县| 鸡东县| 敦煌市| 汕尾市| 庄河市| 高要市| 津南区| 桐乡市| 三门峡市| 洞头县| 逊克县| 新巴尔虎右旗| 广平县| 广宗县| 宣武区| 察哈|