How to hide menu items in Orchard 1.5.1?

Topics: Troubleshooting
Sep 11, 2012 at 3:00 AM

I've created a few page content types and added the 'content permissions' module. I was able to correctly get 'access denied' on my pages based on roles. However, I was hoping to also hide the page from the menu as well.

The Code in NavigationManager.cs in the Reduce method looks like it is trying to hide the menu item but the code is not working. Through the debugger, i stepped through each menu item and noticed that none of the menu items have any permission objects regardless of who I logged in as.

Has anyone else experienced this? is there a fix for it yet?

Sep 11, 2012 at 6:54 PM

Hi,

I guess it's the same issue as reported here: https://orchard.codeplex.com/discussions/289052

However, haven't got any solution so far either. Perhaps it will come with 1.6 :-).


Best regards,
Johann

Oct 15, 2012 at 9:16 PM

I found the problem:

Orchard.ContentPermissions.Security.AuthorizationEventHandler line 55. (looking at the 1x branch):

            if (context.Permission == Core.Contents.Permissions.ViewContent) {

Context.Permission will never equal Core.Contents.Permissions.ViewContent when all the NavigationManager is doing is creating:

new [] { Permission.Named("ViewContent") 
 
As a workaround I changed the line to read:

            if (context.Permission.Name == Core.Contents.Permissions.ViewContent.Name) {