Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breadcrumbs #75

Closed
tiagojsag opened this issue Sep 21, 2011 · 8 comments
Closed

Breadcrumbs #75

tiagojsag opened this issue Sep 21, 2011 · 8 comments

Comments

@tiagojsag
Copy link

Hi,

I've looked around but couldn't find any way to easily render a breadcrumb, so I developed my own BreadcrumbRenderer. Should you think it's useful to others and within the wanted scope of this project, let me know and I'll push it.

@docteurklein
Copy link
Contributor

There is a method to get a "breadcrumb-ready" array : https://github.com/knplabs/KnpMenu/blob/master/src/Knp/Menu/MenuItem.php#L744, but it's true there is no renderer for that.

Please open a PR to let us see what it looks like, thanks!

@pulse00
Copy link

pulse00 commented Nov 28, 2011

@tiagojsag: will you open a PR for your renderer? we need this too and we'd otherwise create one for breadcrumbs.

@tiagojsag
Copy link
Author

Hi,

Right now I have no availability to handle a PR on this subject, because my code doesn't take into account the existing functionality described above, which means I'd have to spend time I unfortunatly don't have on modifications.

I'd suggest you open your own PR. I'll try to stop by and contribute if I can, but no promises on that :(

Good luck!

@pulse00
Copy link

pulse00 commented Nov 28, 2011

okay, thanks for the info.

@sterrien
Copy link

Did you achieved something interesting ?

Here is what I've done :
I have a service for my Menu object and I use a specific template.

{{ knp_menu_render('main', {'template': '::breadcrumb.html.twig'}) }}

The breadcrumb.html.twig template :

{% block root %}
    {%- for  label,url in item.currentItem.breadcrumbsArray %}
        {%- if loop.index > 1 %} > {% endif %}
        {%- if not loop.last %}<a href="{{ url }}">{{ label | trans }}</a>
        {%- else %}<span>{{ label | trans }}</span>
        {%- endif %}
    {%- endfor %}
{% endblock %}

@tunght13488
Copy link

@sterrien I tried your code but it turn out there's no currentItem method in the class Knp\Menu\MenuItem

Still trying to render the breadcrumb.

@sterrien
Copy link

sterrien commented Apr 5, 2013

This method has been removed (see commit KnpLabs/KnpMenu@34ab1df).

I'm not up to date on my project. So it still works ;-)

@jmontoyaa
Copy link

See this PR KnpLabs/KnpMenu#45

EmmanuelVella pushed a commit to EmmanuelVella/KnpMenuBundle that referenced this issue Sep 23, 2020
Standardized testing in accordance with component documentation (in PR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants