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

 

[SOLVED] Module problem with hookHeader

2 replies to this topic
#1
jl_monteagudo

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
Hello all,

I'm developing a module but I'm stuck with a problem that don't let me continue. I would be grateful if somebody could help me.

I want that the module insert a javascript file and an CSS file in the HEADER section of the resultant HTML. So I have defined in the module the following function:

    
function hookHeader($params)
{
return $this->display(__FILE__, 'contentslider-header.tpl');
}


function hookHome($params)
{
return $this->display(__FILE__, 'contentslider.tpl');
}



The content of the file contentslider.tpl is inserted inside the BODY section, but the content of the file contentslider-header.tpl is not inserted. It seems that the function hookHeader is never called!!! I have been studying other modules to see if I'm doing something wrong, but I think that the module is OK.

I've attached the module, so you can see the problem.

Than you very much in advance,

Jose Luis Monteagudo

Attached Files



#2
rocky

    PrestaShop Superstar

  • US Moderators
  • 9988 posts
You forgot to add the header hook to the install function. You should change line 22 from:


if (!parent::install() OR !$this->registerHook('home'))


to:


if (!parent::install() OR !$this->registerHook('home') OR !$this->registerHook('header'))


then when the module is installed, it will be added to both the home and header hooks.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

#3
jl_monteagudo

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
Rocky, thank you very much for your help!!

This was my first module, so I didn't know that. I'm not a PHP developer (I'm a Java guy) but I'm quite impressed with the modularity of Prestashop.

Best regards,

Jose Luis Monteagudo