Post by mfive » Wed Apr 06, 2011 8:23 am

Hi gang,

I'm new to opencart and am trying to understand how this works. Can someone explain this for me?

Very simple example... In the footer of Opencart you see the text: "Powered By OpenCart
Your Store © 2011 | OpenCart Hosting"

When I look in view/theme/default/template/common/footer.tpl - I see where it's outputted fromecho $text_powered_by;

I thought that the variables used in the template files came from the controller. When I look in the footer.php controller, there is no $this->data['text_powered_by'] like I thought I would see. However, if I look in the language folder, I do see $_['text_powered_by'] = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';

Can anyone elaborate on what's going on here? Does the language file also create a variable for use inside the view/template .tpl file?

And if so, in this instance, where does the text "Your Store" and "2011" come from, where it says %s in the actual string text for the variable inside the language footer.php file.

I hope that makes sense.

Thanks in advance for your help!

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by qahar » Wed Apr 06, 2011 12:14 pm

The text come from language

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by mfive » Wed Apr 06, 2011 7:50 pm

In this instance, where does the text "Your Store" and "2011" come from, where it says %s in the actual string text for the variable inside the language footer.php file.

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by Qphoria » Thu Apr 07, 2011 12:39 am

catalog/language/english/common/footer.php:

Code: Select all

$_['text_powered_by'] = 'Powered By <a href="http://www.opencart.com">OpenCart</a><br /> %s &copy; %s';
catalog/controller/common/footer.php:

Code: Select all

$this->data['text_powered_by'] = sprintf($this->language->get('text_powered_by'), $this->config->get('config_name'), date('Y', time()));
catalog/view/theme/default/template/common/footer.tpl

Code: Select all

<?php echo $text_powered_by; ?>
The sprintf function replaces all "%s" found in the language variable with the eval data specified with each comma in the function

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mfive » Thu Apr 07, 2011 2:55 am

I can't believe I missed that in the controller file. It all makes perfect sense, now! Thanks Qphoria!

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am
Who is online

Users browsing this forum: No registered users and 12 guests