Reputation: 137
I try to create a custom Hook for Prestashop 1.7.0.3 for the slider module. I insert:
displaySlider:
- ps_imageslider
on theme.yml file on block “hooks”. Then insert:
{if $page.page_name == 'index'}
{hook h='displaySlider'}
{/if}
on theme/templates/layouts/layout-both-columns.tpl file between header and section id=”wrapper” tags. According to this article: Custom Hooks in Prestashop 1.7 everything will work ok but the hook is not shown on available hooks when i try to change slider module position from the backend.
Upvotes: 3
Views: 12878
Reputation: 127
So just to be clear. To add a new hook in Prestashop.
custom_hooks: - name: displayYourCustomHook - title: displayYourCustomHook - description: This is a Custom hook
displayYourCustomHook: - ps_moduleIwantoHook - ps_anotherModuleIwantToHook
... {hook h='displayYourCustomHook'} ...
This is working in Prestashop 1.7.7
Upvotes: 3
Reputation: 664
I see I voted myself for the accepted solution 2 years ago, but now came up with a much better solution. According to Prestashop 1.7 hooks doc all you have to do is to register your hook as any other normal and it will be automatically created. So paste something like:
$this->registerHook('displayAtSpecificPlace');
in your module install() and reinstall the module.
Upvotes: 0
Reputation: 1
I spent a lot of time looking for why my custom hook did not appear on the front, thanks for the tip.
In order to improve the process, you can use the reset button in appearance > themes & logo.
This avoids having to activate another theme.
Upvotes: 0
Reputation: 126
I was working today on the same issue.
And i succeed to make it appear, it is probably not the good way and i hope it is not the good way because it is weird.
In your theme.yml you have to set your hook like this :
global_settings:
hooks:
custom_hooks:
- name: displayFooterBefore
title: displayFooterBefore
description: Add a widget area above the footer
And if you wanna see your hook in the position page, you have to switch to a other template and back to your one. (Kind of refresh)
You can also check the incomplete doc from Prestashop : http://developers.prestashop.com/themes/hooks/index.html
I hope there is a another way to refresh hooks in this page...
Upvotes: 7