Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Triggering hooks


In the PrestaShop source code, you will find two types of hook triggers:

  • In .php file, it will be the Hook::exec('hookName') method

  • In .tpl file, it will be the {hook h='hookName'} Smarty function

In our case, in /classes/controllers/ProductController.php, you will find the following code:

Hook::exec('displayProductTabContent');

This function will execute all the functions named hookDisplayProductTabContent of the modules attached to this hook in the order defined by the positions we talked about earlier.

The return value of each function will be concatenated and returned by the Hook::exec function. The displayProductTabContent hook is generally used to display blocks at the bottom of the product page. If we look closer at the line containing the trigger (I simplified the following lines on purpose to focus on the essentials), we will see this:

$this->context->smarty->assign(array('HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this-&gt...