问题
Is it possible to integrate javascript in a module without a direct injection in the template smarty?
回答1:
Solved ,
I added a Js file in my module directory (ex : mymodule/views/js/abo_front.js). In my module class, I created a Hook to the header to declare my js file in the header.
public function install()
{
return parent :: install() && $this->resetDb()
&& $this->registerHook('header');
}
public function hookHeader($params)
{
$this->context->controller->addJS(($this->_path).'views/js/abo_front.js');
}
来源:https://stackoverflow.com/questions/17806136/how-to-add-javascript-in-a-prestashop-module