Sylius:如何在网格中引用自己的树枝模板? [英] Sylius: How to reference your own twig template in a grid?

查看:88
本文介绍了Sylius:如何在网格中引用自己的树枝模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是例如在Twig/Symfony2中引用模板,因为不建议将捆绑包作为应用程序创建推荐了,因此答案不再适用.如何在Sylius网格中引用我自己的模板?

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?

我尝试过的:

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"

(我根据文档尝试了其中的一些: https://docs.sylius.com/en/1.6/components_and_bundles/bundles/SyliusGridBundle/field_types.html#twig-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?

推荐答案

如何创建网格或自定义网格?例如,我正在尝试自定义管理">目录">选项"网格,因此通过

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"

第二,我在/templates中创建文件夹"Order",然后在"Order"目录中创建"Grid"文件夹,然后在"Grid"目录中创建文件夹"Field".在那里,我创建带有任何内容的文件"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?

这篇关于Sylius:如何在网格中引用自己的树枝模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆