I have searched for an answer for this without any success. Maybe someone else had ran into this?
I used to use the twig function "include". Eg, in my header.twig, I use to use this line:
{% include 'default/template/common/mobile-nav.twig' %}
Simply like a php include call. Now, upgrading to Opencart 3.0.3.5, this render in an error like this:
Fatal error: Uncaught Twig\Error\LoaderError: Template "default/template/common/mobile-nav.twig" is not defined in "default/template/common/header.twig" at line 34
Anyone got an idea how to rewrite this?
I used to use the twig function "include". Eg, in my header.twig, I use to use this line:
{% include 'default/template/common/mobile-nav.twig' %}
Simply like a php include call. Now, upgrading to Opencart 3.0.3.5, this render in an error like this:
Fatal error: Uncaught Twig\Error\LoaderError: Template "default/template/common/mobile-nav.twig" is not defined in "default/template/common/header.twig" at line 34
Anyone got an idea how to rewrite this?
well personally I would put this in your controller anyway ..
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Well, you might as well update again because 3.0.3.6 is now out.
In any case there were updates to twig and the twig adapter class.
Its now using \Twig\Loader\ArrayLoader. vs the \Twig\Loader\FilesystemLoader, I don't understand why the loader was changed, but problem most likely lies there.
If you want to use twig include partials again, I suspect you will need to add some functionality. Twigs documentation gives some options on how to implement.
In any case there were updates to twig and the twig adapter class.
Its now using \Twig\Loader\ArrayLoader. vs the \Twig\Loader\FilesystemLoader, I don't understand why the loader was changed, but problem most likely lies there.
If you want to use twig include partials again, I suspect you will need to add some functionality. Twigs documentation gives some options on how to implement.
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
We had a solution for this proposed on github a while ago, I don't know why it hasn't been adopted by OpenCart:
https://github.com/opencart/opencart/pu ... -500143157
https://github.com/opencart/opencart/pu ... -500143157
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Try specifying the path from the index.php...
We keep product lists in a single file with conditionals for showing controls (eg: single layout for category, search, module, etc).
We also do the same thing for breadcrumbs...
Note: Our paths are for 4.0.2.3, but this approach may work for you.
Code: Select all
{% include 'extension/my_theme/catalog/view/template/product/product_list.twig' %}
We also do the same thing for breadcrumbs...
Code: Select all
{% include 'extension/my_theme/catalog/view/template/common/breadcrumbs.twig' %}
For OpenCart 3.0.3.8 to 3.0.4.x releases see also this solution.
Having said that, in a proper MVC design you shouldn't use certain twig tags or functions, such as the include. Symfony Twig is of a poor design as it is, and it should only be used a template language, business logic belongs to the controller.
Having said that, in a proper MVC design you shouldn't use certain twig tags or functions, such as the include. Symfony Twig is of a poor design as it is, and it should only be used a template language, business logic belongs to the controller.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
If OC had a few more partial views we wouldn't use includes
- Was nice to see 'product/thumb.twig' in a separate file.
- Breadcrumbs should have got the same treatment.
Who is online
Users browsing this forum: No registered users and 5 guests