Method “currentAncestor” for object “Knp\Menu\MenuItem” does not exist in Sonata

梦想的初衷 提交于 2019-12-21 21:34:50

问题


I'm new to Symfony2 and I just installed it along with fosUserBUndle 1.3.3, Sonata Admin BUndle, and Sonata User BUndle. Now I get an error that I cannot resolve.

Here is my error:

(url localhost:8000/profile/ ) :

Method "currentAncestor" for object "Knp\Menu\MenuItem" does not exist in 

SonataBlockBundle:Block:block_side_menu_template.html.twig at line 29

I am able to login succesfully, but I get this error after login. Any help would be greatly appreciated.

Thanks


回答1:


open file block_side_menu_template.html.twig at /var/www/html/MySymProject/vendor/sonata-project/block-bundle/Resources/views/Block/block_side_menu_template.html.twig

look at line 22 :

{%- if item.current %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif item.currentAncestor %}
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}

Edit to :

{%- if matcher.isCurrent(item) %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif matcher.isAncestor(item, options.depth) %} 
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}

you can visit this link below to find the answer :

https://gist.github.com/mrflory/2278437#file-knp_menu-html-twig-L22



来源:https://stackoverflow.com/questions/25793518/method-currentancestor-for-object-knp-menu-menuitem-does-not-exist-in-sonata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!