Hi,
I am trying to add a menu item to the ApplicationMenuItem . In the MenuContributor.cs class, the following code returns the list of menu items: var administration = context.Menu.GetAdministration();
Is it possible to extend the ApplicationMenuItem, and add a new Menu item under Admin tab, from the module I created? Or do I have to download the volo module for Admin Menu items and add it there?
Any help would be appreciated.
Thanks,
Jesse
- ABP Framework version: latest
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
6 Answer(s)
-
0
Hi, Do you ask creating your own section like below?
var administration = context.Menu.GetAdministration(); var mySection = new ApplicationMenuItem("MySection", "My Section", "#", "fa fa-file"); administration.AddItem(mySection); mySection.AddItem(new ApplicationMenuItem("MySubMenu", "My Sub Menu 1", "#")); mySection.AddItem(new ApplicationMenuItem("MySubMenu2", "My Sub Menu 2", "#")); mySection.AddItem(new ApplicationMenuItem("MySubMenu3", "My Sub Menu 3", "#")); var mySubMenu4 = new ApplicationMenuItem("MySubMenu4", "My Sub Menu 4", "#"); mySubMenu4.AddItem(new ApplicationMenuItem("MySubMenu4A", "My Sub Menu 4.A", "#")); mySubMenu4.AddItem(new ApplicationMenuItem("MySubMenu4B", "My Sub Menu 4.B", "#")); mySection.AddItem(mySubMenu4);
-
1
Or you can add your custom menu under existing module menu:
var administration = context.Menu.GetAdministration(); var languagesMenu = administration.FindMenuItem(LanguageManagementMenuNames.GroupName); languagesMenu.AddItem(new ApplicationMenuItem("MySubLanguageMenu", "My Sub Language Menu", "#"));
-
0
Thank you Enisn, this worked!
-
0
Hi Enisn,
Further to this question, how can I make the menu items I added invisible when the user is NOT logged in?
Thanks for your help!
Jesse
-
0
Hi,
You can use
.RequireAuthenticated()
extension method for MenuItem:var administration = context.Menu.GetAdministration(); var languagesMenu = administration.FindMenuItem(LanguageManagementMenuNames.GroupName); var menuItem = new ApplicationMenuItem( "MySubLanguageMenu", "My Sub Language Menu", "#") .RequireAuthenticated(); // <-- You add this method. languagesMenu.AddItem(menuItem);
-
0
Thank you very much Ensin!
Jesse