我想在其中添加一个脚本,但是使用事件我找不到它的工作方式。
我安装了一个事件,该事件添加了一个脚本,但它显示在HTML标记之前。但我想在head标签内显示。
扩展/模块/shop.php
class ControllerExtensionModuleShop extends Controller {
public function index() {
//$this->document->addStyle('catalog/view/javascript/css/test.css');
//$this->document->addScript('catalog/view/javascript/js/test.js');
echo "<script src="catalog/view/javascript/js/test.js" type="text/javascript"></script>";
}
}
管理员
class ControllerExtensionModuleShop extends Controller {
public function install() {
$this->model_setting_event->addEvent('shop', 'catalog/view/common/header/before', 'extension/module/shop/index');
}
public function uninstall() {
$this->model_setting_event->deleteEventByCode('shop');
}
答案 0 :(得分:0)
使用此触发器添加事件:
$this->model_setting_event->addEvent('shop', 'catalog/controller/common/header/before', 'extension/module/shop/index');
您的shop.php
应该是:
<?php
class ControllerExtensionModuleShop extends Controller {
public function index(&$route = '', &$data = array(), &$output = '') {
$this->document->addScript('catalog/view/javascript/js/test.js');
}
}