Jump to content

Problem creating and using a new hook


Recommended Posts

Hi. First of all sorry for my poor English.

I am newbie using Ps, and I am finding a problem while trying to add a new hook.

I spent many hours reading documentation and tutorials about how should I do this, but I cannot get the desired result so I am writing to find a little help.

 

I just want to create a new hook for a simple banner, so I followed these steps.

 

1) Hook creation by adding a record to ps_hooks. My hook is called 'displayBanner'.

The record created looks like:

 

 

2) FrontController.php - initContent function edition

'HOOK_BANNER' => Module::hookExec('displayBanner')

 

3) Module (blockadvertising.php) edition:

I added:

public function hookdisplayBanner($params)
{
return $this->hookRightColumn($params);
}

 

I also tryed with hookDisplayBanner y hookBanner function names.

 

4) Tpl edition: header.tpl.

<div class="grid_50">
					 <div class="alpha grid_50 omega">
					  {$HOOK_BANNER}
							</div>
					</div>
					 <div class="clear"></div>

 

 

 

Module 'moved' to the new hook

post-148670-0-19247800-1349178036_thumb.png

 

All seems to be right.

post-148670-0-73737800-1349178044_thumb.jpg

 

 

Result

When I visit the frontend, the place where the module is supposed to be placed is just empty.

 

 

Please, I need some help.

Link to comment
Share on other sites

Hi,

Write the below code snippet in: override/classes/controller/FrontController.php

class FrontController extends FrontControllerCore
{
public function initContent()
{
parent::initContent();
if ($this->context->getMobileDevice() == false){
$this->context->smarty->assign('HOOK_BANNER', Hook::exec('displayBanner'));
}
}
}

  • Like 2
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...