KnpLabs / KnpLabs/KnpMenu

knp_menu_render_breadcrumb function

Open
#24 4 comments 1 reaction 0 assignees View on GitHub
Improvement
Dominant language
PHP
Stars
1.4k
Forks
189
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

No implementation file or test is named. Start with the existing knp_menu_render and knp_menu_get Twig entry points and the currentItem.breadcrumbsArray usage shown in the issue. Done means a Twig breadcrumb function accepts the proposed menu name or MenuItem and supports optional appended titles and URLs, with coverage for those inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.