如何在 prestashop 模块中添加 javascript [英] How to add javascript in a prestashop module
本文介绍了如何在 prestashop 模块中添加 javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在模板中不直接注入 smarty 将 javascript 集成到模块中?
Is it possible to integrate javascript in a module without a direct injection in the template smarty?
推荐答案
已解决,
我在我的模块目录中添加了一个 Js 文件(例如:mymodule/views/js/abo_front.js).在我的模块类中,我创建了一个到头文件的钩子来在头文件中声明我的 js 文件.
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');
}
这篇关于如何在 prestashop 模块中添加 javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文