Sylius(Symfony)覆盖模板

时间:2016-04-07 14:34:09

标签: symfony twig sylius


我想覆盖名为productIndex.html.twig的模板,该模板位于vendor/sylius/sylius/src/Sylius/Bundle/WebBundle/Resources/views/Backend/ProductArchetype/productIndex.html.twig。所以我将此文件复制到app/Resources/SyliusWebBundle/views/Backend/ProductArchetype/productIndex.html.twig,就像Symfony documentation所说的那样。但Symfony仍然从vendor渲染这个。我使用Sylius v0.17.0 standard edtion我如何解决它?

1 个答案:

答案 0 :(得分:0)

对于Sylius,您需要首先将Resource配置覆盖到您自己的捆绑包,然后覆盖指向您自己的模板的路由。

sylius.yml

sylius_variation:
    classes:
        product:
            variant:
                controller: MyApp\Bundle\CoreBundle\Controller\VariantController

src/MyApp/Bundle/WebBundle/Resources/views/Backend/ProductVariant/index.html.twig

{% extends 'SyliusWebBundle:Backend:layout.html.twig' %}

{% from 'SyliusWebBundle:Backend/Macros:misc.html.twig' import pagination %}
{% from 'SyliusWebBundle:Backend/ProductVariant:macros.html.twig' import list_all %}
{% import 'SyliusResourceBundle:Macros:buttons.html.twig' as buttons %}

{# Do whatever you want #}