我已经安装了 SonataAdminBundle 和 SonataUserBundle,我正在尝试覆盖一些 Twig 模板。除了 user_block.html.twig 之外,我已经成功地完成了所有工作
这是我的项目 ../app/Resources/目录结构:
Resources/
├── ApplicationSonataUserBundle
│ └── views
│ ├── Admin
│ │ └── Core
│ │ └── user_block.html.twig <--- it doesn't work
│ ├── layout.html.twig
│ ├── Profile
│ │ ├── action.html.twig
│ │ ├── edit_authentication.html.twig
│ │ ├── edit_profile.html.twig
│ │ └── show.html.twig
│ └── Security
│ └── login.html.twig
├── SonataAdminBundle
│ └── views
│ └── standard_layout.html.twig
└── TwigBundle
└── views
└── Exception
└── error.html.twig
我也试过把它放在 SonataAdminBundle 或 SonataUserBundle 目录下,但没有,它对我不起作用。
如何覆盖 user_block 模板?
谢谢
最佳答案
或者,您可以使用配置,如下所示:
sonata_admin:
templates:
layout:
user_block: '::Admin/user_block.html.twig'
然后把你的模板放在这里:
app/Resources/views/Admin/user_block.html.twig
关于symfony - 如何覆盖 SonataUserBundle 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22957679/