来自默认的knp菜单捆绑模板:
{%- elseif matcher.isAncestor(item, options.matchingDepth) %}
{%- set classes = classes|merge([options.ancestorClass]) %}
options.ancestorClass等于" Current_ancestor"。有没有办法覆盖这一点?我不想复制涵盖50行代码的Wohle块项目代码,我只需要更改一个值。
要在所有应用程序中应用默认选项,您可以将knp_menu.renderer.twig.options
参数设置为这样:
// app/config/services.yml
parameters:
knp_menu.renderer.twig.options:
currentClass: active
KnpMenuRendererTwigRenderer
的默认选项是:
$this->defaultOptions = array_merge(array(
'depth' => null,
'matchingDepth' => null,
'currentAsLink' => true,
'currentClass' => 'current',
'ancestorClass' => 'current_ancestor',
'firstClass' => 'first',
'lastClass' => 'last',
'template' => $template,
'compressed' => false,
'allow_safe_labels' => false,
'clear_matcher' => true,
'leaf_class' => null,
'branch_class' => null,
), $defaultOptions);
尝试
{{ knp_menu_render('AcmeDemoBundle:Builder:mainMenu', {'ancestorClass': 'your-class'}) }}
来自此链接