Can I add a menu without permission required in the main menu? If yes whats my wrong?
CustomModuleNavigationProvider
public class CommerceServiceNavigationProvider : NavigationProvider
{
public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu
.AddItem(
new MenuItemDefinition(
PageNames.Commerce,
L("HomePage"),
url: "App/Commerce",
icon: "fa fa-home"
)
).AddItem(
new MenuItemDefinition(
PageNames.About,
L("About"),
url: "App/About",
icon: "fa fa-info"
)
);
}
private static ILocalizableString L(string name)
{
return new LocalizableString(name, CommerceServiceConsts.LocalizationSourceName);
}
}
CustomModuleWebModule
public class CommerceServiceWebModule : AbpModule
{
public override void PreInitialize()
{
Configuration.Navigation.Providers.Add<CommerceServiceNavigationProvider>();
Configuration.EmbeddedResources.Sources.Add(
new EmbeddedResourceSet(
"/Views/",
Assembly.GetExecutingAssembly(),
"CommerceService.Web.Views"
)
);
Configuration.Modules.AbpAspNetCore()
.CreateControllersForAppServices(
Assembly.GetExecutingAssembly()
);
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(CommerceServiceWebModule).GetAssembly());
}
}
Then I used [DependsOn(typeof(CommerceServiceWebModule)] attribute at MyAppWebCoreModule But nothing to show
3 Answer(s)
-
0
Hi,
Is it Angular or MVC?
If it's Angular, according to the doc <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Angular#main-menu-and-layout">https://aspnetzero.com/Documents/Develo ... and-layout</a>
Main menu is defined and rendered in side-bar.component. You can add new menu items here. You generally relate a menu item to an Angular route. Angular routes are defined in several modules:
- app/admin/admin-routing.module defines routes for admin module.
- app/main/main-routing.module defines routes for main module.
- app/app-routing.module defines general routes and the default route.
If it's MVC+JQuery <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Core#main-menu">https://aspnetzero.com/Documents/Develo ... #main-menu</a>
Application's main menu is defined in AppNavigationProvider class. See ABP's navigation documentation to have a deep understanding on creating menus. When you add a new menu item, it's automatically rendered in the layout. Main menu is rendered in menu component. Layout also highly uses bundling & minification (see the section below) system for script and style includes.
-
0
Hi.
<cite>alper: </cite> Is it Angular or MVC?
It's MVC. Navigation source place's is my wrong? I created this using ABP documents. I asked a question
<cite>csbeginner: </cite> Can I add a menu without permission required in the main menu? If yes what's my wrong?
but after waiting for 7 hours and refreshing topic page's I resolved a link not YES or NO.
-
0
Hi,
Your code seems fine. What is the value of context.Manager.MainMenu in CommerceServiceNavigationProvider when you debug the code ?
You can also try to change your menu definition like below in CommerceServiceNavigationProvider and give it a try;
var menu = context.Manager.Menus["App"] = new MenuDefinition("App", new FixedLocalizableString("Main Menu"));