我想在移动版本中加载一些js文件到prestashop模块,这个问题只出现在移动版本中,我有这个代码
public function install() {
return parent :: install()
&& $this->registerHook('displayCenterleftColumn') &&
$这 - > registerHook( '标头'); }
public function hookHeader($params)
{
//Tools::addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css');
//Tools::addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css');
$this->controller->addCSS(($this->_path).'front/css/param_product.css');
//$this->context->controller->addCSS('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/ui-lightness/jquery-ui.css');
//$this->context->controller->addCSS(_PS_ROOT_DIR_."spinner/ui.spinner.css");
//$this->context->controller->addJS("http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js");
$this->controller->addJS(_MODULE_DIR_."blockcart/ajax-cart.js");
$this->controller->addJS(($this->_path).'front/js/functions.js');
$this->controller->addJS(($this->_path).'front/js/main.js');
$this->controller->addJS(($this->_path).'front/js/jquery.validate.js');
}
在header.tpl中的其他问题是这个代码
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
我在哪里可以设置$ js_files变量。
感谢。
答案 0 :(得分:0)
首先,卸载新模块。
其次,将此代码放入您的模块中:
function install() {
if (!parent::install())
return false;
if (!$this->registerHook('displayCenterleftColumn'))
return false;
if (!$this->registerHook('header'))
return false;
return true;
}
第三步,再次安装你的模块。
你的问题是使用'Header'进入安装功能,这是一个不正确的值。正确的值是'标题'。
问候并祝你好运!
答案 1 :(得分:0)
我解决了这个问题,我在模块安装文件中添加了一个displayhookMobile函数
public function hookdisplayMobileHeader($params) in which i assigned my js and css file
public function hookdisplayMobileHeader($params){
$this->context->controller->addJS(_MODULE_DIR_."blockcart/ajax-cart.js");
$this->context->controller->addJS(($this->_path).'front/js/functions.js');
$this->context->controller->addJS(($this->_path).'front/js/main.js');
$this->context->controller->addJS(($this->_path).'front/js/jquery.validate.js');
}