简体   繁体   中英

Registering hook in Prestashop module

I am trying to register header hook to display my text:

//install function
return parent::install() &&
            $this->registerHook('header');
public function hookHeader()
    {
        $this->context->controller->addJS($this->_path.'/views/js/front.js');
        $this->context->controller->addCSS($this->_path.'/views/css/front.css');
    }

what that I get when trying to transparent:

Hooks are already registered

I think you should use : actionFrontControllerSetMedia / actionAdminControllerSetMedia to register yours js and css.

public function install()
{
    return parent::install() &&
        $this->registerHook('actionAdminControllerSetMedia');
}
public function hookActionAdminControllerSetMedia()
{
    $this->context->controller->addJS($this->_path.'/views/js/front.js');
    $this->context->controller->addCSS($this->_path.'/views/css/front.css');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM