Jump to content

Adding new hook


BMGMartin

Recommended Posts

Hello, I've downloaded and installed Prestashop 1.6.1.0 on my localhost.

I've been trying to create a new hook, but without any luck. I've been following this tutorial

 

http://nemops.com/adding-hooks-to-prestashop-1-5/#.Va0NPfntlBc

 

I'm using the default preinstalled template.

 

1

C:\xampp\htdocs\Eshop\themes\default-bootstrap\footer.tpl

 

.......
{if isset($HOOK_FOOTER)}
{hook h='beforeFooter'}   <!-- new code -->
<!-- Footer -->
<div class="footer-container">
<footer id="footer"  class="container">
.......

2

C:\xampp\htdocs\Eshop\modules\homeslider\homeslider.php

.........
public function install()
{

/* Adds Module */
if (parent::install() &&
$this->registerHook('displayHeader') &&
$this->registerHook('displayTopColumn') &&
$this->registerHook('actionShopDataDuplication') &&
$this->registerHook('beforeFooter')  /* new code */
)
{
........

and at the end of the file

 

..............
public function hookBeforeFooter($params)
{
return 'hi there!';
}


}

*******************

Where is the problem? Nothing shows up on the page and there isn't a new entry in the ps_hook in the database either. I've tried to add the hook into the db manually, but it had no effect.

Anyone knows what could be wrong? 

 

Link to comment
Share on other sites

  • 2 months later...

Hi there,

I seen same issue and this my way resolved it:

 

  1. rename public function hookBeforeFooter($params) to public function hookbeforeFooter($params)
  2. in DB find ps_hook table go to the end check beforeFooter created?
  3. clear cache, from admin backend go to Advanced Parameters > Performance click "Clear cache" button on top right corner.
  4. in Smarty section choose Recompile templates if the files have been updated

I use prestashop 1.6.1.1 (you can try steps: 1, 3, 4 before). Good luck!

Edited by thanhvk (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Make sure you have the hook installed and positioned in the correct hook.

If not you will need to reinstall the module.

If its positioned in the new hook just call the hook in the template in a clean area (not inside any if statement).

Link to comment
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
×
×
  • Create New...