问题
This is not a duplicate of e.g. Referencing a template in Twig / Symfony2 because creating bundles as applications is deprecated/not recommended anymore and therefore the answer is not applicable anymore. How do I reference my own template in a Sylius grid?
What I tried:
1.
options:
template: "@App/Order/Grid/Field/channel.html.twig"
2.
options:
template: ":Order/Grid/Field:channel.html.twig"
3.
options:
template: "templates/Order/Grid/Field/channel.html.twig"
4.
options:
template: "Order/Grid/Field/channel.html.twig"
(I tried some of these on the basis of the documentation: https://docs.sylius.com/en/1.6/components_and_bundles/bundles/SyliusGridBundle/field_types.html#twig-twig , https://docs.sylius.com/en/1.6/components_and_bundles/bundles/SyliusGridBundle/your_first_grid.html)
In all cases it says the template was not found. Any ideas?
回答1:
How do you create grid or customize them? For example, I am trying to customize Admin > Catalog > Options grid, so by this tutorial put these lines at the end of config/packages/_sylius.yaml
file:
sylius_grid:
grids:
sylius_admin_product_option:
fields:
name:
type: twig
options:
template: "Grid/mytemplate.html.twig"
Secondly, I create folder "Order" in /templates, then "Grid" folder in "Order" dir, and then folder "Field" in "Grid" directory. There I create file "mytemplate.html.twig" with any content. Did you tried similar steps?
来源:https://stackoverflow.com/questions/59648295/sylius-how-to-reference-your-own-twig-template-in-a-grid