Jump to content
vblanch

[MODULE] Hook Manager

Recommended Posts

Hi everyone.

Together with a partner, we recently developed a new theme for an online store. To do this we needed to introduce new hooks in the store, design themes . While programming it , we realized that the hooks in PrestaShop is highly dependent on modules (eg calling the function "registerHook" , restart the module, etc... ) And also sometimes you have to touch the database if you want the new hooks to display in "Positions" and be able to associate modules to them.

So I developed a module that lets you create, edit and remove hooks in an easy way from the control panel of Prestashop. This module also allows you to show or hide the hooks in positions.
 

The module is completely free and is released under the GPL2 license.
 

It has been developed for Prestashop 1.5.x version, I didn't try it on a 1.4.x, if I see that people are interested I may do the adaptation to these versions.

 

*EDIT: I addapted the code so now it's compatible with 1.4.x and even maybe with 1.3.x (didn't try), just download v1.0.3 of the module or higher*

The module is multilingual.

If this module really makes your life easier and you want to support my work you can make a donation, in the configure screen of the module it's specified how.
 

Thank you!

Installation and use :

1. Put the "hookmanager" folder in "modules" .

2. Enable the module in Modules (control panel) .

3. In Modules, click the "Configure" button on the Hooks Manager module.

4. Create, modify or delete hooks.

Note : You can leave the module activated once done (it's status does not affect the hooks you've created / modified / deleted).

 

You can alse see the code or fork it in GitHub: https://github.com/vblanch/hookmanager_ps_module

 

Version History:

1.0.0-1.0.1: Initial release/some typos fixed.

Update 1.0.2: Changed "Create" for "New Hook" and the german translation is now correct, thanks to eleazar!

1.0.3 Added compatibility with Prestashop 1.4.x, maybe 1.3.x but I didn't try, you are free to test it. Also hooks are sorted alphabetically now. Some debug code removed, some typos in comments fixed.

1.0.4 Removed translations that I'm unable to keep updated, and added compatibility with Prestashop 1.6.x. Now it's possible to set the title and the description of the hook!

Edited by vblanch

Share this post


Link to post
Share on other sites

Well this is an excelent module. Just what I was looking for. If it does what i think it does :)

 

Going to install it right now.

Thx for making the module free.

Share this post


Link to post
Share on other sites

Well this is an excelent module. Just what I was looking for. If it does what i think it does :)

 

Going to install it right now.

Thx for making the module free.

 

Hi there abondares,

you are welcome. Hope it's useful for you.

If you have any suggestions to improve it just tell me ;)

Share this post


Link to post
Share on other sites

Hello,

 

I am interested in this module too. Is it possible to make the changes and adapt it to PS 1.4.x ?

 

Kind regards,

 

Marianna

Share this post


Link to post
Share on other sites

Hello,

 

I am interested in this module too. Is it possible to make the changes and adapt it to PS 1.4.x ?

 

Kind regards,

 

Marianna

 

Hi Marianna,

I just added compatibility with 1.4.x.

Give it a try, it should work.

Regards

Share this post


Link to post
Share on other sites

Bonjour et merci pour ce module. depuis une mise à niveau en 1.5.6.2 depuis 1.5.6.1 j' ai ce bug.

 

! ) Notice: Undefined variable: html in C:\wamp\www\monsite\modules\hookmanager\hookmanager.php on line 153 Call Stack # Time Memory Function Location 1 0.0014 403168 {main}( ) ..\index.php:0 2 0.1737 7560312 DispatcherCore->dispatch( ) ..\index.php:53 3 0.2995 12824840 ControllerCore->run( ) ..\Dispatcher.php:348 4 0.8000 15937248 AdminModulesControllerCore->postProcess( ) ..\Controller.php:158 5 0.8001 15938848 AdminModulesControllerCore->postProcessCallback( ) ..\AdminModulesController.php:811 6 0.8099 16066264 HookManager->getContent( ) ..\AdminModulesController.php:685 7 0.8099 16066400 HookManager->displayForm( ) ..\hookmanager.php:139

 

Quelqu'un pourrait il m'aider .Merci

Share this post


Link to post
Share on other sites

Does it work in Prestashop 1.6 ?

 

It would be great if it works in 1.6

 

Give it a try, it should work now in PS 1.6!

 

Donations are highly appreciated :-)

Share this post


Link to post
Share on other sites

Hi, Greetings

I am having an error installing the module and when to I want to edit. Here a screenshot of the error:

Is an updated PS 1.5 to 1.6.0.8 store, the store works well. Install a clean version in PS 1.6.0.8 and this not get the bug. Any idea what It could be?

 

Share this post


Link to post
Share on other sites

Hi, Greetings

I am having an error installing the module and when to I want to edit. Here a screenshot of the error:

Is an updated PS 1.5 to 1.6.0.8 store, the store works well. Install a clean version in PS 1.6.0.8 and this not get the bug. Any idea what It could be?

 

I get the same error. I am on fresh PS 1.6.0.8 install.

 

edit:

I think this is caused because $html variable has a Concatenation assignment (.=) in both if cases (either line 162 or 165). 

 

I initialized $html on line 160 by setting $html = null; and the message is gone.

 

Edited by HaCos

Share this post


Link to post
Share on other sites

Give it a try, it should work now in PS 1.6!

 

Donations are highly appreciated :-)

 

Can you explain how exacly does it work?

I created a a new hook and it is succefully listed in positions. I face 2 issues: 

1. No matter which module i try to transplant to this hook, it doesnt work. I get the error msg : This module cannot be transplanted to this hook.

2. How will this hook show up in template? Dont we need to add the hook name in the .tpl files in order to get loaded there?

 

Regards,

C

Share this post


Link to post
Share on other sites

Hi, Greetings

I am having an error installing the module and when to I want to edit. Here a screenshot of the error:

Is an updated PS 1.5 to 1.6.0.8 store, the store works well. Install a clean version in PS 1.6.0.8 and this not get the bug. Any idea what It could be?

 

Hi there,

first of all, thanks for using it and for the feedback. Do not worry about the "Notice" messages. They are more like warnings, no real errors.

 

I get the same error. I am on fresh PS 1.6.0.8 install.

 

edit:

I think this is caused because $html variable has a Concatenation assignment (.=) in both if cases (either line 162 or 165). 

 

I initialized $html on line 160 by setting $html = null; and the message is gone.

 

You are right, initializing the variable will fix the notice. I will push that change into the next version.

 

Can you explain how exacly does it work?

I created a a new hook and it is succefully listed in positions. I face 2 issues: 

1. No matter which module i try to transplant to this hook, it doesnt work. I get the error msg : This module cannot be transplanted to this hook.

2. How will this hook show up in template? Dont we need to add the hook name in the .tpl files in order to get loaded there?

 

Regards,

C

 

1. You create the hook for the modules, however you must add extra code to the modules themselves in order to be able to be added to this hook. For instance, if your hook is called "test", you must have a function in the module you want to add to the hook called "hookTest". You can copy the inner workings of that function from another on the same module (for example if it has a hookTop function or similar).

 

2. Hook will show in template if you call it. There's special smarty code in order to "call" a hook. Please take a look at the header.tpl or footer.tpl in your theme, you should find something like "{$HOOK_HEADER}". In order to call the hook, you must add other extra code too. Here is an example: http://www.prestashop.com/forums/topic/203786-to-call-home-hook-in-all-other-template-files-in-prestashop/

 

I hope this all clarifies things a bit :)

 

Cheers

Share this post


Link to post
Share on other sites

You are right, initializing the variable will fix the notice. I will push that change into the next version.

 
Already created a pull request :)

1. You create the hook for the modules, however you must add extra code to the modules themselves in order to be able to be added to this hook. For instance, if your hook is called "test", you must have a function in the module you want to add to the hook called "hookTest". You can copy the inner workings of that function from another on the same module (for example if it has a hookTop function or similar).
 
2. Hook will show in template if you call it. There's special smarty code in order to "call" a hook. Please take a look at the header.tpl or footer.tpl in your theme, you should find something like "{$HOOK_HEADER}". In order to call the hook, you must add other extra code too. Here is an example: http://www.prestashop.com/forums/topic/203786-to-call-home-hook-in-all-other-template-files-in-prestashop/
 
I hope this all clarifies things a bit :)
 
Cheers

Thanks for the info, i ll give a try and let you know.

Regards,
C

Share this post


Link to post
Share on other sites

I get the same error. I am on fresh PS 1.6.0.8 install.

 

edit:

I think this is caused because $html variable has a Concatenation assignment (.=) in both if cases (either line 162 or 165). 

 

I initialized $html on line 160 by setting $html = null; and the message is gone.

 

Thanks Hacos for change, works for me.

 

 

 

Hi there,

first of all, thanks for using it and for the feedback. Do not worry about the "Notice" messages. They are more like warnings, no real errors.

 

 

Thanks

Share this post


Link to post
Share on other sites

I just updated the code, now the "$html" notice shouldn't show anymore. So if you don't want to edit the code just download the file and overwrite the old module.

 

Cheers

Share this post


Link to post
Share on other sites

I just updated the code, now the "$html" notice shouldn't show anymore. So if you don't want to edit the code just download the file and overwrite the old module.

 

Cheers

 

Ready! Overwritten. :)

Share this post


Link to post
Share on other sites

Hello I have presta shop 6 I have installed your module but when I am going in themeconfigurator I can not see the hook which I name profooter, could you tell me what do I have to do?

Thanks

Marina

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×