簡體   English   中英

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

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM