KnpLabs/KnpMenu — Issue #24: knp_menu_render_breadcrumb function
Author: dbu
Created: 2012-01-10 13:44:06+00:00
State: open

it would be great to have a breadcrumb twig function similar to the knp_menu_render for the menu.

the function should expect either the menu name and then pick the currentItem based on the menu, or expect a MenuItem from which it builds the breadcrumb.
an additional cool feature would be to pass an optional array of titles and urls to append to the breadcrumb in case there is no menu item for the last entries in the breadcrumb (e.g. consider a menu item for an overview of postings and a breadcrumb on the details page of one posting. )

currently we have this code in twig to render a breadcrumb:

{% set currentItem = knp_menu_get('main').currentItem %}
{% if currentItem %}

{% for title, url in currentItem.breadcrumbsArray %}

{{ title }}

{% endfor %}

{% endif %}

/cc @uwej711