Create Hooks in 6 easy steps!

Took me quite a while and lots of meddling to figure this out… thought I would share with the rest of you guys on how to create a hook so u can NOT waste the number of hours like I did.

1. Goto your database and modify ps_hook… (ps_ is what I named my database, so it can be replaced by what you named yours.)

2. find the last id_hook number and insert a new number after with the hook that you want to name e.g. I name it ‘cat’

3. goto the php of the pages you want the hook to be in… e.g footer.php

4. insert ‘HOOK_CAT’ => Module::hookExec(‘cat’), into the below

$smarty->assign(array(
        'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),
        'HOOK_FOOTER' => Module::hookExec('footer'),
        'content_only' => intval(Tools::getValue('content_only'))));
$smarty->display(_PS_THEME_DIR_.'footer.tpl'); 

5. this is the final code…

$smarty->assign(array(
        'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn'),
        'HOOK_FOOTER' => Module::hookExec('footer'),
        'HOOK_CAT' => Module::hookExec('cat'),
        'content_only' => intval(Tools::getValue('content_only'))));
$smarty->display(_PS_THEME_DIR_.'footer.tpl'); 

6.insert {$HOOK_CAT} into where you want in footer.tpl and you are in business

NOTE : For the hook to appear YOU HAVE TO assign the array in the page’s php… Would be good if we can have a master HOOK array list…

See Original Post and more information

affiliate_link
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

One Response to “Create Hooks in 6 easy steps!”

Trackbacks are disabled.

  • Lucas Fogolin says:

    Being a newbie in PrestaShop I don´t understand where do the third step want me to insert the code… shoudn´t it be in the, for example, footer.TPL file? Is it not in the template files? Or am I mistaken and these should be put in the modules files?