addJS function not working for admin in prestashop

后端 未结 5 1776
星月不相逢
星月不相逢 2021-01-14 05:52

I am trying to add javascript file in prestashop admin using backOfficeHeader hook using a module but nothing happened. My code is given below.

         


        
5条回答
  •  抹茶落季
    2021-01-14 06:47

    For me "this->_path" dosn't work. My solution is to use $_SERVER['DOCUMENT_ROOT']

    public function hookActionAdminControllerSetMedia($params)
    {
        // add necessary javascript to products back office
        if($this->context->controller->controller_name == 'AdminProducts' && Tools::getValue('id_product'))
        {
            $this->context->controller->addJS($_SERVER['DOCUMENT_ROOT']."/modules/apl/views/js/jquery.ui.touch-punch.min.js");
        }
    }
    

提交回复
热议问题