Post by slawrence10 » Mon Jul 20, 2009 10:10 pm

Hey,

I want to move the breadcrumbs function from being called in layout.tpl and instead to call it within product.tpl

Is there an easy way to correctly point to the breadcrumbs variable? I'm guessing it is to do with product.tpl being stored elsewhere to layout.tpl?

As at the moment I just get

Code: Select all

Notice: Undefined variable: breadcrumbs 
Thanks for your time,
Scott

Scott Lawrence - Creative agency - Bespoke web and graphic design


User avatar
Active Member

Posts

Joined
Sun Jul 19, 2009 8:10 pm
Location - London, UK

Post by slawrence10 » Tue Jul 21, 2009 7:29 am

OK

I managed to get this to work. So for anyone who this could be useful for in the future....

In order to declare breadcrums (the Navigation bar at the top of each page) that looks like this
Home > Category > Product

in the Product template
i.e CATALOG > VIEW > THEME > DEFAULT > TEMPLATE > PRODUCT> PRODUCT.TPL

I done the following...
In CATALOG > CONTROLLER > PRODUCT > PRODUCT.PHP after LINE 174 I insterted

Code: Select all

$this->data['breadcrumbs'] = $this->document->breadcrumbs;
You can then call breadcrumbs within PRODUCT.TPL like you do in LAYOUT.TPL

Code: Select all

<?php foreach ($breadcrumbs as $breadcrumb) {
echo $breadcrumb['separator']; ?>
<a href="<?php echo $breadcrumb['href']; ?>">
<?php echo $breadcrumb['text']; ?></a>
<?php } ?>

Scott Lawrence - Creative agency - Bespoke web and graphic design


User avatar
Active Member

Posts

Joined
Sun Jul 19, 2009 8:10 pm
Location - London, UK

Post by readyman » Wed Jul 22, 2009 11:10 pm

Yes, in short ANY variable you want available in a template file must be set in the corresponding controller.
eg. layout.php -> layout.tpl or product.php -> product.tpl

Before attempting any coding please read up on the framework of opencart here - http://www.opencart.com/forum/viewtopic.php?f=20&t=4113

http://www.alreadymade.com
Follow me on twitter.com/alreadymade


User avatar
Global Moderator

Posts

Joined
Wed May 20, 2009 5:16 am
Location - Sydney
Who is online

Users browsing this forum: Amazon [Bot] and 3 guests