Hello all,
I'm new to OpenCart and am working to learn its structure so I can best make design changes to suit my web store. As there is currently no documentation available for cusomization, etc. I'm exploring these key components on my own and making notes as I go along (I'll be happy to share what I discover).
As a newbie and an old school programmer I'm first puzzled by where the variables used in the PHP and TPL files are loaded, modified, etc.
Here's a simple example from the home.tpl file:
div class="heading">
So where does the $heading_title variable come from? How can it be modified? Can anyone shed any light on this? Sorry if this is too basic a question, but I'm just cutting my teeth on this stuff.
It's exported via the "view" library class.
It takes a bit of time to get to grips with, but you'll pick it up...
It takes a bit of time to get to grips with, but you'll pick it up...
Pay no attention to all those big words.. 
The setup is based on 3 main components:
Controller files = code
Language files = language
Template files = display or view
Using your question as an example, in the catalog/controller/home.php file there is:
$view->set('$heading_title', $language->get('heading_title');
which shows that it is setting a variable in the view to the value of the language heading_title.
If you want to change the contents, then you'd change the catalog/language/english/controller/home.php file under the "heading_title" variable
means that the variable that the controller file knows as "mainaction", it is passing it to a view variable called simply $action. So in the controller you'd be changing the code for $mainaction and in the tpl file you'd be referencing just $action

The setup is based on 3 main components:
Controller files = code
Language files = language
Template files = display or view
Using your question as an example, in the catalog/controller/home.php file there is:
$view->set('$heading_title', $language->get('heading_title');
which shows that it is setting a variable in the view to the value of the language heading_title.
If you want to change the contents, then you'd change the catalog/language/english/controller/home.php file under the "heading_title" variable
means that the variable that the controller file knows as "mainaction", it is passing it to a view variable called simply $action. So in the controller you'd be changing the code for $mainaction and in the tpl file you'd be referencing just $action
Who is online
Users browsing this forum: No registered users and 1 guest