F
Filamentβ€’4w ago
mile4841

How to order naviation groups

Hi everyone is there a way i can reorder navigation groups for now if i am using the navigationSort is not working
8 Replies
mile4841
mile4841β€’4w ago
i find the solution, it is to defined the in the AdminPanelProvider your groups
->navigationGroups([
NavigationGroup::make('Blog')
->label('Blog'),
NavigationGroup::make('Permissions'),

NavigationGroup::make('Admin users')
->label('Admin users'),
])
->navigationGroups([
NavigationGroup::make('Blog')
->label('Blog'),
NavigationGroup::make('Permissions'),

NavigationGroup::make('Admin users')
->label('Admin users'),
])
TheRealTeeHill
TheRealTeeHillβ€’4w ago
you can also do it like this in AdminPanelProvider.php if you don't need the functionality from NavigationGroup::make πŸ™‚
$panel->navigationGroups([
'Nav Group 1',
'Nav Group 2',
'Nav Group 3',
])
$panel->navigationGroups([
'Nav Group 1',
'Nav Group 2',
'Nav Group 3',
])
mile4841
mile4841β€’4w ago
Thanks
MilenKo
MilenKoβ€’7d ago
Hello. I've got into the same trouble as the author of the post, however adding the navigastionGroups to AdminPanelProvider does not seem to resolve my navigation groups order and instead they are ordered in an Alphabetical order. Here is my navigationGroups markup:
// Define the navigation groups state (open/closed by default)
->navigationGroups([
NavigationGroup::make()
->label('Employees Management')
->collapsed(),
NavigationGroup::make()
->label('Users Management')
->collapsed(),
NavigationGroup::make()
->label('System Management')
->collapsed(),
]);
// Define the navigation groups state (open/closed by default)
->navigationGroups([
NavigationGroup::make()
->label('Employees Management')
->collapsed(),
NavigationGroup::make()
->label('Users Management')
->collapsed(),
NavigationGroup::make()
->label('System Management')
->collapsed(),
]);
However the order is strangely set to: Employees Management, System Management and Users Management Any ideas how can I resolve the order as I've been reading and reading documentations and followed several tutorials, however so far the only way to reorder the navigation groups was by using the following suggested code related to translations:
// Define the navigation groups order and labels
->navigationGroups([
'Users Management' => NavigationGroup::make(fn() => __('Users Management')),
'Employees Management' => NavigationGroup::make(fn() => __('Employees Management'))->collapsed(false),
'System Management' => NavigationGroup::make(fn() => __('System Management')),
]);
// Define the navigation groups order and labels
->navigationGroups([
'Users Management' => NavigationGroup::make(fn() => __('Users Management')),
'Employees Management' => NavigationGroup::make(fn() => __('Employees Management'))->collapsed(false),
'System Management' => NavigationGroup::make(fn() => __('System Management')),
]);
Having used this code DOES ORDER my groups in any way I need them, however it ignores the state of the navigation group and I cannot set it as collapsed(false) Btw, using the shorter version of ordering (just for the sake of testing):
->navigationGroups([
'System Management',
'Users Management',
'Employees Management',
]);
->navigationGroups([
'System Management',
'Users Management',
'Employees Management',
]);
Did not order the navigation groups as well... Besides I need to be able to define the state of a group (eiter it is collapsible or not)...
TheRealTeeHill
TheRealTeeHillβ€’7d ago
in AdminPanelProvider I use
->navigationGroups([
'Z',
'X',
'Y',
])
->navigationGroups([
'Z',
'X',
'Y',
])
and it shows Z first in the nav so maybe there is something overriding it, maybe post your entire AdminPanelProvider
MilenKo
MilenKoβ€’6d ago
@TheRealTeeHill Yes., that is what I use presently and I confirm it works fine now, however in the format you shared and I use, you cannot define the label, icon, collapsed() and any other properties there are but just the order. Here is the scenario I am aiming: Have navigation groups A, B, C which all have own icon and A is collapsed, B - not, C - collapsed too. I noticed that the collapsed state is somehow stored per user ( I guss it is in the session or local) but by default we should be able to define if a navigation group should be "Open" or "Closed" And yes, I know it is more common to provide the icons in the sub-navigation items, but what if you just want to have icons on the navigation group itself (and the functionality is already provided) ....
TheRealTeeHill
TheRealTeeHillβ€’6d ago
@MilenKo are you wanting to use an icon for the nav group and for the nav group sub-items? as I don't think you can do that...? For the nav group part, I will need to take another look this weekend πŸ‘
MilenKo
MilenKoβ€’6d ago
@TheRealTeeHill Obviously the way the Filament is configure I cannot have icons on both and that is sad as many websites have such ui/ux but it is what it is. My news is to set the order of the navigation groups and have every group with its own icon (only for the group) not for the child items. Having just the navigation groups in the desired order listed does help to order but does not allow me to change label, set an icon, definitely the colaps state and so forth... I can define the icon using the code provided in the demo but that does not order them and they appear in A-Z state even if they were placed differently in the panel config
Want results from more Discord servers?
Add your server