PrestaShop Forums: [SOLVED] Module problem with hookHeader - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


[SOLVED] Module problem with hookHeader


[SOLVED] Module problem with hookHeader

#1 jl_monteagudo

    PrestaShop Newbie

  • 18 Jun 2010
  • Members
  • Pip
  • 2 posts

Posted 30 July 2010 - 03:06 PM

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 File(s)



#2 rocky

    PrestaShop Superstar

  • 16 Oct 2008
  • US Moderators
  • 9981 posts
  • Location:Australia

Posted 31 July 2010 - 03:30 AM

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.

Guides Performance Guide | Installation Guide | Development Guide

Modules AJAX Sliding Categories | AJAX Dropdown Categories | Carousel | Image Gallery | Sliding Menu

All free and paid software, modules, themes and modifications are subject to the terms and conditions here.

#3 jl_monteagudo

    PrestaShop Newbie

  • 18 Jun 2010
  • Members
  • Pip
  • 2 posts

Posted 31 July 2010 - 09:27 PM

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users