-
Notifications
You must be signed in to change notification settings - Fork 191
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
[WIP] Breadcrumb renderer #161
base: master
Are you sure you want to change the base?
Conversation
The way to do a Breadcrumb for now: // Random example
$menu = $menuFactory->createItem('Homepage');
// Getting the last node aka "new message" here
$endOfTree = $menu->addChild('Forum')->addChild('Topic')->addChild('New Message');
$manipulator->getBreadcrumbsArray($endOfTree); That mean that you need to have a direct access to the last node of a menu. 2 things are wrong in that sentence:
New POV proposal on this feature:
The usage would be quite similar. <?php
$breadcrumb = $breadcrumbFactory->createItem('Homepage');
$breadcrumb->addChild('Forum')->addChild('Topic')->addChild('New Message');
$manipulator->getBreadcrumbsArray($endOfTree); Differences:
Limitations:
Anything against this proposal ? I will be working on after some guys tell me what they think about. |
@Nek- The goal of this breadcrumb was to build the breadcrumb automatically based on the same menu you use for the navigation elsewhere. The breadcrumb is the path in the tree to reach the current item (which can be determined using the voter system, if you don't have a more efficient way to find it). Your proposal looks weird, because it propose to use the ItemInterface in a way which does not respect the interface (ItemInterface is designed as a tree).
Getting the parent of a menu item is efficient (if I was designing the library from scratch, it may be different as I would probably try to avoid the circular reference in the object graph, but this is off-topic). The issue is more about getting the current item than about moving up in the tree.
when rendering a given item, you always have access only to the item being rendered right now, not to the whole menu. The difference is the way you move to another item. |
Thank you for explainations about the feature :) . (I never used it) But you never render a menu by yourself. And in a menu render you never need to render a breadcrumb. So how do you get the node in another part of your website ? I made a little sample application and it was not so easy to use the breadcrumb renderer because of I needed the last node. Do you have an example ? |
Can we maybe move this forward? I'm trying to update the CMF sandbox to use KnpMenuBundle 2.0 (as it's now required by Sonata). I'm currently unable to transform the code we used to render the breadcrumb with KnpMenu 1 to KnpMenu 2. At the moment, one would need to iterate over the tree and use the matcher to get the current item and pass it to |
Is this PR focusing on building out a breadcrumb that has links or just a string? I think |
This PR could be in 2.1 if it doesn't pass before the end of the beta.
And she needs:
Problem: How to retrieve the current item without parsing the complete tree menu.