How to add javascript in a prestashop module

孤者浪人 提交于 2019-12-10 23:38:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!