PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

 

Create new hooks

6 replies to this topic
#1
meiosdecomunicacao

    PrestaShop Newbie

  • Members
  • Pip
  • 1 posts
How can i create and associate new hooks on my new theme.

This is the way i'm doing it, but it's not working

a) Create the new hook on table 'hook'


| ID | NAME | TITLE | DESCRIPTION | POSITION |
--------------------------------------------
| 32 | test | Test | Test Hook | 1 |


b) Add a hookTest function to the module and create the tpl file if necessary


function hookTest($params)
{
...
}


c) Transplant the module to the hook i've just created.
d) Add the {$HOOK_TEST} in the theme.
c) Test it.

Result: Nothing happens.

#2
Damien Metzger

    PrestaShop Fanatic

  • PrestaTeam
  • 1243 posts
Hi,

{$HOOK_TEST} must be assigned from the php file which has called the tpl.
If you want this in product.tpl for example, you have to add the following line in product.php :
$smarty->assign('HOOK_TEST', Module::hookExec('test'));

(Something like that at least ^^)

#3
hieloiceberg

    PrestaShop Apprentice

  • Members
  • PipPip
  • 480 posts
Hello all can anybody guide me in the right direction on how to make a simple hook I have try what Damien says but have no idea where to add the code or what do I need to do to make it work!!

I will appreciated very much if anybody helps me out.

Thank you very much!
FarmVille Addict ;-)

#4
hieloiceberg

    PrestaShop Apprentice

  • Members
  • PipPip
  • 480 posts
I need a hook anybody? :lol:
FarmVille Addict ;-)

#5
hieloiceberg

    PrestaShop Apprentice

  • Members
  • PipPip
  • 480 posts
Sweet!! made my first Hook %-P

Attached Files


FarmVille Addict ;-)

#6
Travis

    PrestaShop Apprentice

  • Members
  • PipPip
  • 105 posts

From 1232493800:

Sweet!! made my first Hook %-P


lol :-)

#7
Katmatcreations

    PrestaShop Apprentice

  • Members
  • PipPip
  • 326 posts
lol now he is hooked!