我想覆盖名为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
我如何解决它?
答案 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 #}