I am using the opencart open source e-commerce website. The main problem I am having is when I try to separate the breadcrumbs into a single file that I include inside each .tpl file. I have tried using the basic PHP include method although this does not work.
In Reply to Jay's answer:
I have created a new breadcrumbs controller that renders the separate breadcrumb template file.
<?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();
}
}
?>
Although this causes the error:
Notice: Undefined variable: breadcrumbs
To do this, you need to first set the breadcrumb template as a child of the controller action using $this->children, then echoing out the breadcrumbs with that. You will also need to set the id of the breadcrumb controller, so that you know what to echo in your template
Personally I would just add the breadcrumbs to the common/header.tpl file instead, it's far easier
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.