[英]OpenCart Make $products Available in home.tpl File
I'm trying to make the latest products available in the home.tpl file. 我正在尝试在home.tpl文件中提供最新产品。 I've modified the catalog/controller/module/latest.php from:
我从以下位置修改了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';
}
to: 至:
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';
}
But $products is shown to be an Undefined variable: products
once the page loads. 但是$ products显示为一个
Undefined variable: products
页面加载后的产品。 How would I make $products available on home.tpl? 我如何在home.tpl上提供$ products?
Note: I have the Latest module loaded with the Layout set to Home and the Position set to Content Top. 注意:我加载了“最新”模块,其中“布局”设置为“主页”,“位置”设置为“内容顶部”。
You shouldn't have to modify anything in terms of templates for this to work. 您无需针对模板进行任何修改即可使其正常工作。
Content Top is a child process and is rendered via the controller class whenever it's included in the $children
array. Content Top是一个子进程,只要它包含在
$children
数组中,就会通过controller类呈现。
Check your $children
array in the home controller, it should look like this: 检查家庭控制器中的
$children
数组,它应如下所示:
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
Check your home.tpl
and ensure that the variable $content_top
exists. 检查您的
home.tpl
并确保变量$content_top
存在。
Make sure the Latest module is enabled
. 确保
enabled
了“最新”模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.