[英]OpenCart Make $products Available in home.tpl File
我正在尝试在home.tpl文件中提供最新产品。 我从以下位置修改了catalog / 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上提供$ products?
注意:我加载了“最新”模块,其中“布局”设置为“主页”,“位置”设置为“内容顶部”。
您无需针对模板进行任何修改即可使其正常工作。
Content Top是一个子进程,只要它包含在$children
数组中,就会通过controller类呈现。
检查家庭控制器中的$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
了“最新”模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.