E
E
Evanre2016-03-04 04:33:53
PHP
Evanre, 2016-03-04 04:33:53

How to correctly pass a variable to OpenCart2?

Can you please tell me how to correctly pass a variable in from controll to view? I can't do it at all.
I'll give you a real example:

catalog\language\english\product\product.php
$_['text_sizes'] = 'Sizes';
catalog\controller\product\product.php
$data['text_sizes'] = $this->language->get('text_sizes');

catalog\view\theme\journal2\template\product\product.tpl
<div class="prodsizeslabel text"><?php echo $text_sizes; ?></div>

There are simply no mine in the scope of incoming variables. I duplicate the adjacent line with the declaration of the variable, I give the variable a different name, the adjacent variable is there, mine is not. Can it be that variables or files with them are cached?
ps And please advise a resource-help on OpenCart, preferably more or less active.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Silm, 2016-03-04
@Evanre

Everything in the array $datais passed to the template.
Try
0. Clean system/cache cache and vqmod/cache.
1. Modify a built-in value that is accurately output. If it doesn't change, then something is wrong.
2. Make sure that the controller in which you add the variable calls the view in which you display. There may be confusion, with topics, for example.
3. Dump the variable in the controller and kill the script. var_dump($var); die();. The browser should display the dump on a white screen. If nothing happened, then you are not editing the controller that you are calling. Or not that place of the controller.
docs.opencart.com - there is some information in the developer section
forum.opencart.com - official community
well, a domestic resource: https://opencartforum.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question