Hy!
I need to use some data in twig files, how do I pass it from header.php to twig files? I created a new element in $data array, but It doesn't exist in the twig files.
$data['testvar'] = "test string";
And I try to access it in twig files like this:
{{ testvar }}
After you made some changes, you must in admin dashboard refresh your modifications and clear cache, blue gear icon in right upper corner.
If you add $data['testvar'] = "test string";
only in catalog/controller/common/header.php
, than you can use {{ testvar }}
only in catalog/view/theme/Your theme (or default)/template/common/header.twig
.
To be sure what $data is communicate to view file, you can add die(print_r($data));
before load view.