Jump to content

I have a custom module and I'm trying to extends a Twig template in the product view, but I'm encountering issues with extending the Twig in the product's view.


Mac Story

Recommended Posts

Heya!

I also got the same issue with u Mr. Mac, I am trying to extend by adding a supplier name on the product list under the order details but when I do, I also get the same error message.

Here is my sample extended file

image.png.456fbebf3c846483cfcf8ea579834fdc.png

 

Link to comment
Share on other sites

Hello,

Your problem is most likely the fact that you are using the display method, or some similar method, which should be used only for smarty templates.

For twig templates, you need to use the render method.

If you are in a module main file, here is the syntax that you need to use: 

return $this->get('twig')->render('@Modules/<module_name>/views/templates/admin/test.twig', []);

You will need to replace that first argument with your information. The array is the data passed to the template.

If you are in an admin controller that extends FrameworkBundleAdminController, you directly have access to the render method.

Link to comment
Share on other sites

19 hours ago, Andrei H said:

Hello,

Your problem is most likely the fact that you are using the display method, or some similar method, which should be used only for smarty templates.

For twig templates, you need to use the render method.

If you are in a module main file, here is the syntax that you need to use: 

return $this->get('twig')->render('@Modules/<module_name>/views/templates/admin/test.twig', []);

You will need to replace that first argument with your information. The array is the data passed to the template.

If you are in an admin controller that extends FrameworkBundleAdminController, you directly have access to the render method.

Thanks! This one worked for me.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...