我正在使用 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