Post by oolongtea » Thu Jun 09, 2011 6:39 am

Hi, I'm new to opencart and have a basic question about the core of opencart.
Can anybody tell me how is the variable being pass to tpl?

on the tpl files, I see alot of $variable but have no idea where they come from.

thanks!
-Ken

Newbie

Posts

Joined
Thu Dec 09, 2010 6:28 am

Post by Qphoria » Thu Jun 09, 2011 7:44 am

This is an example of how to do it:
http://forum.opencart.com/viewtopic.php ... 60#p146671

Basically you create the variable in the controller file that calls the tpl file

Ex

Code: Select all

$this->data['xyz'] = '123';
Then in the tpl file you would call

Code: Select all

<?php echo $xyz; ?>

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by oolongtea » Thu Jun 09, 2011 8:08 am

thanks! that's helpful

Newbie

Posts

Joined
Thu Dec 09, 2010 6:28 am

Post by guldan » Sun Apr 07, 2013 2:40 am

Hi Qphoria,

I'm using Opencart 1.5.4.
I need to echo $link['href'] within product.tpl.
Just type echo $link['href'] in the product.tpl will echo nothing.

We can easily echo $link['href'] in header.tpl, like this code (for canonical link):

Code: Select all

<link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
How to echo it in product.tpl?

Thank you.. :)

Newbie

Posts

Joined
Sat Apr 06, 2013 5:06 pm
Who is online

Users browsing this forum: No registered users and 7 guests