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

Add a weight system to order items on the same branch #176

Closed
Maxwell2022 opened this issue Mar 11, 2013 · 2 comments
Closed

Add a weight system to order items on the same branch #176

Maxwell2022 opened this issue Mar 11, 2013 · 2 comments

Comments

@Maxwell2022
Copy link

It would be great to add an optional weight for the items of the menu. This weight would be used when rendering the menu to order the items located in the same level of the tree.

I know that at the moment if I want an item at the end of the list I have to add it last. But it would simplify a lot of logic in the code if we could use a weight system.

ie. you want to display 5 menu items depending of the user role:

without weight system:

$root->addChild('menu.item1', array('route' => '_my_route1'));
$root->addChild('menu.item2', array('route' => '_my_route2'));

if ($security->isGranted('ROLE_A')) {
   $root->addChild('menu.item3', array('route' => '_my_route3'));
}

$root->addChild('menu.item4', array('route' => '_my_route4'));

if ($security->isGranted('ROLE_A')) {
    $root->addChild('menu.item5', array('route' => '_my_route5'));
}

with a weight system:

$root->addChild('menu.item1', array('route' => '_my_route1', 'weight' => 0));
$root->addChild('menu.item2', array('route' => '_my_route2', 'weight' => 10));
$root->addChild('menu.item4', array('route' => '_my_route4', 'weight' => 20));

if ($security->isGranted('ROLE_A')) {
   $root->addChild('menu.item3', array('route' => '_my_route3', 'weight' => 15));
   $root->addChild('menu.item5', array('route' => '_my_route5', 'weight' => 25));
}

I had a look to the options and could not find it so I guess it's not been implemented for now but I'll be happy to know that I'm wrong :)

Cheers,
Maxime

@stof
Copy link
Collaborator

stof commented Mar 11, 2013

Could you please request it into KnpMenu instead ? the bundle is only about the Symfony2 integration. It will make things easier by keeping the feature request in its right location.

@Maxwell2022
Copy link
Author

Yeah, sure.
KnpLabs/KnpMenu#97

EmmanuelVella pushed a commit to EmmanuelVella/KnpMenuBundle that referenced this issue Sep 23, 2020
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

2 participants