OpenCart将数据传递给子模块

时间:2014-07-18 14:58:33

标签: opencart

基本上我要做的是将一些数据从“父”控制器传递到其子模块的控制器,例如:

标题控制器

$this->children = array(
    'module/newslettersubscribe'
);

newslettersubscribe 控制器

public function index() {
   // Use here data from the header controller
}

这甚至可以吗?

1 个答案:

答案 0 :(得分:0)

这里的方法不正确。您应该只编辑滑块控制器并检查GET(查询字符串)中是否有path变量,例如:

if (!empty($this->request->get['path'])) { /* ... */ }

如果是,您现在可以从其值中提取类别(例如1_12_36):

if (!empty($this->request->get['path'])) {
    $category_ids = explode('_', (string)$this->request->get['path']);
}

现在知道类别ID(或类别路径),您只能使用您编写的任何代码显示相应的图像。

相关问题