OpenCart-在.tpl的内部包含.tpl
-
25-10-2019 - |
题
我正在使用OpenCart开源电子商务网站。我遇到的主要问题是,当我尝试将面包屑分为我每个.tpl文件中包含的单个文件时。我尝试使用基本PHP包括方法,尽管这不起作用。
回答杰伊的回答:
我创建了一个新的面包库控制器,该控制器呈现单独的面包板模板文件。
<?php
class ControllerCommonBreadcrumb extends Controller {
public function index() {
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/breadcrumbs.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/breadcrumbs.tpl';
} else {
$this->template = 'default/template/common/breadcrumbs.tpl';
}
$this->render();
}
}
?>
尽管这导致错误:
Notice: Undefined variable: breadcrumbs
解决方案
为此,您需要首先使用$ this->儿童作为控制器动作的小孩设置面包屑模板,然后以此与面包屑相呼应。您还需要设置BreadCrumb控制器的ID,以便您知道在模板中回荡
我个人只会将面包屑添加到common/header.tpl文件中,这要容易得多
不隶属于 StackOverflow