Post by karlpers » Tue Jul 21, 2020 3:10 am

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?

Active Member

Posts

Joined
Tue Jun 09, 2009 10:35 pm

Post by by mona » Tue Jul 21, 2020 4:06 am

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


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by karlpers » Tue Jul 21, 2020 4:30 am

Yeah, in this particular example it wouldn't be any big problem to put it into the controller. The problem is that I have used the {% include %} on multiple areas :/

Active Member

Posts

Joined
Tue Jun 09, 2009 10:35 pm

Post by sw!tch » Tue Jul 21, 2020 4:28 pm

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.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by JNeuhoff » Tue Jul 21, 2020 6:57 pm

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

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 173 guests