Navigation order - mixing groups and items
I know a variety of similar questions have been asked and Ive read them but I think Im trying the selected answer and not getting the suggested response. Im trying to make a custom menu so that i have 3 navigation items going to urls, then a group (My Account) and then 2 further Navigation items to log out and to go back to a previous website. A cut down version of my requirements is basically like this
However what I get is Dashboard, Item 2 and then the group. Is there something I'm doing wrong ? Thanks for any pointers
Solution:Jump to solution
one off items are put into their own 'group' and prepended to the navigation collection, but you should be able to achieve what you want with this (but the spacing might be weird, but should be adjustable with some custom CSS):
```php
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder...
7 Replies
Groups are always sorted first. Then items.
And items without a group are grouped into one
@Dennis Koch Thanks for the reply. If groups are sorted first, how do they appear beneath my items ? Is there any way of getting
item item item group group item item ? or will it always do item x5 group x2 ?
item item item group group item item ? or will it always do item x5 group x2 ?
I think the algorithm is:
1) Everything is sorted.
2) Then everything is grouped. Items with no group will be in their own category.
=> Therefore it will always be the second one.
You might be able to overwrite that method, I don't know where it is though.
Solution
one off items are put into their own 'group' and prepended to the navigation collection, but you should be able to achieve what you want with this (but the spacing might be weird, but should be adjustable with some custom CSS):
This is probably not the intended use of the NavigationBuilder grouping logic, though, so might be a hack that could potentially break in the future.

Thanks very much Adam. Its for our own system rather than a customer so if it does break in future then i'll revisit. Will apply that now and see how I go. That's very much appreciated.