Question

Can someone tell me how can I have the breadcrumb nav within the header.tpl and not in the product.tpl of opencart?

Was it helpful?

Solution

Due to the way 1.5.X is coded, you'll need to rewrite every controller and add a method back to the document class to allow passing from the product controller to the header controller. Is there any particular reason you want to do so?

OTHER TIPS

I've just had to figure this out for a new site we're building and I've come up with the following; use at your own risk (I'll report back if I run into any major problems, but I can't foresee any... famous last words)

Basically the breadcrumbs are built in the controllers and we need the resulting $breadcrumbs array in the header controller. Modify system/engine/controller.php as follows:

[...snip...]
protected function render() {
    foreach ($this->children as $child) {
        $this->data[basename($child)] = $this->getChild($child,array('parent_data'=>&$this->data));
}
[...snip...]

This will send all the data in the parent controller, before render() was called, to every controller/method of the $children. Then we just need to pick this up in the header controller as follows:

<?php   
class ControllerCommonHeader extends Controller {
    protected function index($args=array()) {
        // parent data
        $this->data['parent_data'] = $args['parent_data'];
[...snip...]

And we can access everything in the template with $parent_data['whatever']. In this case, $parent_data['breadcrumbs'] will be the array of breadcrumbs that I can loop over with the code I've removed from each page.tpl and added to my header.tpl.

if all else fails just hack the css, something like

.breadcrumb {
   margin-left: -270px;
   margin-top: -65px;
}

will move the breadcrumb up and to the left.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top