OpenCart 3. How to work with language variables?

1 мин. на чтение

OpenCart is a great but too much popular versions are. You can easy get project on 1.5.x, 2.x or even 3.x today and this is really trouble.

Several days ago I have made simple changes in 3.x and spend several hours to understand why Controller don’t declare Language variable in regular way like this one:

$_data['text_some'] = $this->language->get('text_some');

but this text there are in twig file!

<p>{{ text_some }}</p>

It’s could be possible due updates. Here is quotes about that:

In OpenCart 3, the language variables are auto loaded into the controller. You don’t need to declare the variables by yourself. So you can add a new variable into the language file (catalog or admin) and then use it directly from your twig view.

My opinion – it’s awesome, now you can reduce your source code and don’t waste a time to declare obvious variables.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.