Answer the question
In order to leave comments, you need to log in
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>
Answer the question
In order to leave comments, you need to log in
Everything in the array $data
is 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 questionAsk a Question
731 491 924 answers to any question