我尝试发送到我的模块prestashop插件。我收到了一条消息"技术验证已被拒绝"。此消息包含
您需要在hookBackOfficeHeader中添加条件,才能将您的文件仅包含在您想要的页面中。
我的hookBackOfficeHeader钩子是:
public function hookBackOfficeHeader()
{
$this->context->controller->addCSS($this->_path.'views/css/back.css');
$this->context->controller->addJquery();
$this->context->controller->addJS($this->_path.'views/js/back.js?v=1.0');
}
我需要使用这个css和js文件只是产品编辑页面和模块配置页面。如何为此页面添加条件?
此致
答案 0 :(得分:3)
有很多方法,我会写得最简单:
public function hookBackOfficeHeader()
{
if(
(Tools::getValue('controller') == 'AdminProducts' AND Tools::getValue('id_product'))
OR
(Tools::getValue('controller') == 'AdminModules' AND
(Tools::getValue('configure') == YOURMODULENAME OR Tools::getValue('module_name') == YOURMODULENAME)
)
){
$this->context->controller->addCSS($this->_path.'views/css/back.css');
$this->context->controller->addJquery();
$this->context->controller->addJS($this->_path.'views/js/back.js?v=1.0');
}
}