Hi
I use Opencart 2.3 and i need variable with language code in header.tpl file.
I use this code (I found this code in this forum)
echo $this->session->data['language'];
but it causes an error.
<b>Notice</b>: Undefined property: Template\PHP::$session in <b>C:\xampp7\htdocs\immunology-shop\catalog\view\theme\immunology\template\common\header.tpl</b> on line <b>102</b><b>Notice</b>: Trying to get property of non-object in <b>C:\xampp7\htdocs\immunology-shop\catalog\view\theme\immunology\template\common\header.tpl</b> on line <b>102</b>
Somebody help me? Please
Template files are outside the scope of that variable (should be worth reading about if you want to develop anything), if you want to use it you need to declare it in the respective controller and then use it in the template, like so.
controller
template
controller
Code: Select all
$this->data['language'] = $this->session->data['language'];
Code: Select all
<?php echo $language; ?>
Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com
Ok I paste in controller header code:
$data['language'] = $this->session->data['language'];
and
code echo $language;
in header.tpl not work.
Are You sure. It not work for me?
$data['language'] = $this->session->data['language'];
and
code echo $language;
in header.tpl not work.
Are You sure. It not work for me?
my website: Tworzenie sklepu internetowego
Who is online
Users browsing this forum: No registered users and 264 guests