OpenCart Make $ products在home.tpl文件中可用

时间:2013-08-22 17:11:41

标签: php templates undefined opencart

我正在尝试在home.tpl文件中提供最新产品。我已经修改了目录/ controller / module / latest.php:

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/latest.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/module/latest.tpl';
} else {
    $this->template = 'default/template/module/latest.tpl';
}

为:

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/common/home.tpl';
} else {
    $this->template = 'default/template/common/home.tpl';
}

但是一旦页面加载,$ products就会显示为Undefined variable: products。我如何在home.tpl上提供$产品?

注意:我将最新模块加载了布局设置为主页,位置设置为内容顶部。

1 个答案:

答案 0 :(得分:0)

您不必修改模板方面的任何内容。

Content Top是一个子进程,只要它包含在$children数组中,就会通过控制器类进行渲染。

检查家庭控制器中的$children阵列,它应如下所示:

$this->children = array(
    'common/column_left',
    'common/column_right',
    'common/content_top',
    'common/content_bottom',
    'common/footer',
    'common/header'
);

检查您的home.tpl并确保变量$content_top存在。

确保最新模块为enabled

相关问题