Page 1 of 1

Twig {% include %} function changed in Opencart 3.0.3.5

Posted: Tue Jul 21, 2020 3:10 am
by karlpers
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?

Re: Twig {% include %} function changed in Opencart 3.0.3.5

Posted: Tue Jul 21, 2020 4:06 am
by by mona
well personally I would put this in your controller anyway ..

Re: Twig {% include %} function changed in Opencart 3.0.3.5

Posted: Tue Jul 21, 2020 4:30 am
by karlpers
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 :/

Re: Twig {% include %} function changed in Opencart 3.0.3.5

Posted: Tue Jul 21, 2020 4:28 pm
by sw!tch
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.

Re: Twig {% include %} function changed in Opencart 3.0.3.5

Posted: Tue Jul 21, 2020 6:57 pm
by JNeuhoff
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