【问题标题】:Unable to override KnpMenuBundle template无法覆盖 KnpMenuBundle 模板
【发布时间】:2014-06-26 00:38:13
【问题描述】:

使用...MyBundle\Resources\views\Menu\knp_menu.html.twig,删除</li> 对呈现的菜单没有影响。 (删除标记是为了删除内联列表元素之间的空格。)我遵循了this answer 中提供的建议,包括该帖子底部提到的{% import 'knp_menu.html.twig' as knp_menu %}。这是因为knp_menu.html.twig 已经扩展了knp_menu_base.html.twig?还是什么?

layout.html.twig:

...
{{ render(controller('VolVolBundle:Default:userMenu')) }}
...

用户菜单操作:

$user = $this->getUser();
$tool = $this->container->get('vol.toolbox');
$type = $tool->getUserType($user);
return $this->render(
                'VolVolBundle:Default:userMenu.html.twig', array('type' => $type)
);

userMenu.html.twig

...
{% if type is not null %}
    {% set menu = "VolVolBundle:Builder:"~type~"Menu" %}
    {{ knp_menu_render(menu) }}
{% endif %}

【问题讨论】:

  • 能否请您添加您使用的源代码 - 在您的模板中,在您输出菜单的位置?
  • @SpiRi7:上面添加的代码。

标签: symfony knpmenubundle


【解决方案1】:

in here 深处找到了答案。对模板进行全局覆盖所需的只是修改config.yml

config.yml:

...
knp_menu:
    twig:  # use "twig: false" to disable the Twig extension and the TwigRenderer
        template: VolVolBundle:Menu:knp_menu.html.twig
...

【讨论】:

    猜你喜欢
    • 2014-08-30
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 2015-10-01
    • 2015-02-14
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多