Post by MaximumLife » Wed Sep 25, 2024 9:04 pm

This line is not working for an extension:

Code: Select all

{% include 'extension/module/related_options_edit_variants.twig' %}
I even tried this modification but it did not work.
https://www.opencart.com/index.php?rout ... load_id=62

Please advise
Last edited by MaximumLife on Wed Sep 25, 2024 11:29 pm, edited 1 time in total.

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm

Post by by mona » Wed Sep 25, 2024 9:08 pm

The link for the modification fix has nothing to do with your question.
Contact the extension developer (the one that has twig include - not the one you linked to)

viewtopic.php?t=219092
and again, personally I would put it in the controller

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 JNeuhoff » Wed Sep 25, 2024 10:15 pm

You could try this in a modified system/library/template/twig.php:

Code: Select all

		$loader1 = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
		$loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE)); // to find further includes
		$loader  = new \Twig\Loader\ChainLoader(array($loader1, $loader2));
Having said that, you shouldn't use twig include in a MVC design. Populate the variables for the extension/module/related_options_edit_variants.twig in a separate controller, and then use a twig variable in your template instead of an include:

Code: Select all

{% related_options_edit_variants %}
Last edited by JNeuhoff on Wed Sep 25, 2024 11:29 pm, edited 1 time in total.

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


Post by MaximumLife » Wed Sep 25, 2024 11:28 pm

JNeuhoff wrote:
Wed Sep 25, 2024 10:15 pm
You could try this in a modified system/library/template/twig.php:

Code: Select all

		$loader1 = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
		$loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE)); // to find further includes
		$loader  = new \Twig\Loader\ChainLoader(array($loader1, $loader2));
This, my friend, seemed to do the trick. I put it into an ocmod for others in the future. Simple upload and install.

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm
Who is online

Users browsing this forum: No registered users and 31 guests