Skip to content

Instantly share code, notes, and snippets.

@redleafar
Last active September 4, 2016 09:35
Show Gist options
  • Save redleafar/364fc856882d571035eb43973a6434b3 to your computer and use it in GitHub Desktop.
Save redleafar/364fc856882d571035eb43973a6434b3 to your computer and use it in GitHub Desktop.
Error: Method “currentAncestor” for object “Knp\Menu\MenuItem” does not exist in Sonata
{# app/resources/SonataBlockBundle/views/Block/ block_side_menu_template.html.twig #}
{# Fixed changing this : #}
{%- if item.current %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif item.currentAncestor %}
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}
{# For this : #}
{%- if matcher.isCurrent(item) %}
{%- set classes = classes|merge([options.currentClass]) %}
{%- elseif matcher.isAncestor(item, options.depth) %}
{%- set classes = classes|merge([options.ancestorClass]) %}
{%- endif %}

At:

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

But remember to do it extending the template in app/resources/SonataBlockBundle/views/Block/ block_side_menu_template.html.twig

Already done in Gpstracker project, is just a matter of copy and paste the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment