Opencart-当我在布局中选择它时,模块不会出现


Opencart - Module does not appear when I choose it in Layouts

我想在任何页面中创建一个div,这样我就可以在上使用Jquery

这是我的目录/控制器/模块/test_products.php

class ControllerModuleTestProducts extends Controller {
public function index() {
    $this->document->addScript('catalog/view/javascript/test.js');
    $path = '/template/module/test_products.tpl';
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $path)) {
        $this->template = $this->config->get('config_template') . $path;
    } else {
        $this->template = 'default'.$path;
    }
    return $this->load->view($this->template, $data);
    //$this->render();
}

}

这是我的catalog/view/theme/default/template/module/test_products.tpl

<div id="test-notification" class="abc"></div>

但是当我在布局中打开它时,我的DIV不会出现。我做错了什么?我想我的控制器不工作了。。。

我想您已经在返回时提到$data,但$data变量下没有代码。所以你要么删除$data变量,要么给它赋值。

返回$this->load->view($this->模板,$data);

我想这会对你有所帮助。

谢谢。