Design and CSS styles
Version 5.x > Design and CSS styles > Hide A page(menu Item) from menu if user Role is other than Admin. View modes: 
User avatar
Member
Member
anji.anjee-gmail - 4/15/2010 8:27:06 PM
   
Hide A page(menu Item) from menu if user Role is other than Admin.
Is there any Property that make's page(menu item) in Css list Menu that should be visible to only users who are in Admin Role.For all other users this page should not be visible in the main menu.

Can any one please Guide me in the right direction ?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 4/16/2010 3:42:18 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello,

I think the following article about content personalization should help you to accomplish the described functionality.

Best regards,
Boris Pocatko

User avatar
Member
Member
anji.anjee-gmail - 4/16/2010 10:27:39 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
But the Article Helps in Hiding content to specific users in Roles ,But actually what i need is hide the Link in the Main Menu to all other users except Admin.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 4/20/2010 12:44:30 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello,

Yes, this is how the software is designed. You need to deny access to all other users. A second approach could be to change the "Check permissions:" property of the menu dynamically with a custom macro, which would detect the presence of an global administrator. The following macro returns "true", if the logged in user has Global administrator access rights:

{%currentuser.userisglobaladministrator == "True"%}


Best regards,
Boris Pocatko

User avatar
Member
Member
vlatso-synqsolutions - 5/18/2010 12:24:47 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
I have similar problem as anji.anjee has. I have read the article you mentioned but I am not able to hide a menu item.
What I need to do is to hide My Account menu item from main menu unless the user is authenticated. This menu has submenus and I do not want the public see the items.
I added “Authenticated users” role to Users and Roles of Properties->Security and checked Allow Read. Added also “Not authenticated users” and checked Deny Read. After that I clicked “Break inheritance and copy parent permissions.” And selected Requires authentication. I would expect that this is sufficient to not to show the menu item to public but it is there.

Thanks

Vlado

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/18/2010 12:52:10 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello,

Have you tried to follow the instructions which are described in our Developer's guide under the following section?

http://devnet.kentico.com/docs/devguide/index.html?displaying_personalized_content.htm

Best regards,
Boris Pocatko

User avatar
Member
Member
vlatso-synqsolutions - 5/18/2010 12:54:51 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Yes, this is what I meant with this sentence:
vlatso-synqsolutions wrote: I have read the article you mentioned but I am not able to hide a menu item.

What could I possibly be doing wrong?

Thanks.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/18/2010 1:27:07 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello,

The described approach should work without problems. Could you please try to create a test menu and try to follow the instructions step by step and maybe use a different pair of roles?

Best regards,
Boris Pocatko

User avatar
Member
Member
vlatso-synqsolutions - 5/19/2010 1:21:43 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
I tried it and created a Test page.
Here are the steps I used:
1. New Page, name it Test
2. Test->Properties->Security->users and roles
a. Authenticated users : Read: Allow
b. Not authenticated users: Read: Deny
3. Test->Properties->Security->Access
a. Requires authentication: yes
4. Test->Properties->Security->Permissions: Break inheritance and copy parent permissions

The tab is visible for public – not the page. There is login page instead if the user is not logged in. I want to hide the tab for public with a simple setting.

Thanks for your time.

Regards,

Vlado


User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/24/2010 9:21:33 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello,

could you please check your menu web part properties? It should be configured like:

Check permissions: checked


Best regards,
Helena Grulichova

User avatar
Member
Member
vlatso-synqsolutions - 5/24/2010 9:52:34 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello Helenka,

The Check Permission was not checked so I tried to check it. But after that the entire Menu was not visible for not signed users (public). My goal is to hide only one item in the menu – not the entire web part.
So it does not work and remains unresolved.

Vlado

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/25/2010 5:42:04 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello Vlado,


if you use this settings you need to allow explicitly all other menu items for public users. I am not sure what version you use exactly but there is a default role for public users (the name changes with versions). This role needs the read permission for all public menu items (document Properties -> Security tab).

If you change the settings please clear the application cache in Site manager -> Administration -> System.


Best regards,
Helena Grulichova

User avatar
Member
Member
vlatso-synqsolutions - 5/25/2010 7:04:29 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
BINGO!

This was it. It makes sense to do it this way but is not very intuitive. Maybe somebody could write up a step-by-step documentation about it for other users.
Thank you , Helena!

Regards,

Vlado

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/25/2010 7:13:44 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello Vlado,


I am happy it works for you. By the way, the context help for Check permissions settings says: "Indicates if permissions should be checked for the displayed content and only the documents for which the current user has the "read" permission should be displayed." I hope it is clear. However, it could be a nice article for our Knowledge base. Thank you for the suggestion.


Best regards,
Helena Grulichova

User avatar
Member
Member
Aon_Vlado - 6/6/2011 2:32:35 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
As I mentioned above I have learned how to hide/show menuItem according the role using menu web part. Now I am working on a different site where I am forced to use Repeater web part instead of Menu web part and the above approach does not work. I have set deterrent permissions on my pages; check the check box “Check permissions” but all menu items in the repeater web part are visible to all roles. Is it possible to hide/show menu items in repeater? What to do?

Thanks,

Vlado

User avatar
Certified Developer v6
Certified Developer v6
szarouski - 11/18/2011 8:42:15 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hi, based on your answer I found even better solution.
Instead of going and checking all pages to be visible for authenticated users you can do following (used Kentico 6, but hopefully same way will work for Kentico 5+):
For page(s) which should be hidden from non-authenticated users go to properties -> security and add following at Users and Roles: "Authenticated users -> Read - Allow", "Non authenticated users -> Read - Deny"
Access -> Requires authentication: Yes
This will specify that for selected page you want users to be authenticated, allowing them to read the page and disallowing non-authenticated users to read the page.

For your webpart, in System settings -> Check permissions use following macro (click on arrow): "{%CurrentUser.IsInRole("_notauthenticated_")%}"

Using this way you need to configure only webpart and specific page permissions, instead of going through all pages and modifying permissions.

Best regards,
Sergey Zarouski, Seventyeight Digital

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/19/2011 3:37:24 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello.

Thank you for sharing your solution. Both roles (Authenticated and Not authenticated) exist it previous version, too, so it should be useable in previous version as well. Moreover, since Kentico CMS 6, you can use positive evaluation for permissions, so no Deny is required (if positive evaluation is enabled).

Best Regards,
Radek Macalik

User avatar
Certified Developer v6
Certified Developer v6
szarouski - 11/19/2011 8:23:50 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hi Radek, thanks for posting. Can you please describe it better? Should I use another macro? Same place or different? Thank you

User avatar
Kentico Support
Kentico Support
kentico_radekm - 11/23/2011 8:26:55 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hello.

I must to revoke my previous statement. I found out that this functionality has not been implemented in version 6. I am sorry for confusion.

Best Regards,
Radek Macalik

User avatar
Member
Member
andry.poernomo-alyka.com - 1/21/2012 2:20:45 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hi Sergey,

I don't get your following instruction:

For your webpart, in System settings -> Check permissions use following macro (click on arrow): "{%CurrentUser.IsInRole("_notauthenticated_")%}"

how do I use that macro? where do I insert the macro? which arrow are you talking about?

Thank you for your help :)

Andry

User avatar
Certified Developer v6
Certified Developer v6
szarouski - 1/22/2012 9:05:05 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hi, I'm talking about this one
User image
When you click on arrow it will popup with textarea window, so simply insert this macro {%CurrentUser.IsInRole("_notauthenticated_")%} click save, and your checkbox will be replaced with text are with macro inside. Click OK or Apply on webpart window and it will work.

Cheers

User avatar
Certified Developer v6
Certified Developer v6
szarouski - 1/22/2012 9:07:08 AM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Sorry, wrong image path :)

User image

User avatar
Member
Member
andry.poernomo-alyka.com - 1/22/2012 8:53:17 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
where can I find thise page setting? I'm looking at Web parts / Navigation / Drop-down menu / Properties / Check permissions

I think I'm looking at the wrong page! hehehe...

Cheers!

User avatar
Member
Member
anji.anjee-gmail - 5/18/2010 1:02:46 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hi vlatso-synqsolutions ,

What i did is ,i added a new column to Page Menu Document isAdmin.Now this field is visible as a check box in form field of ever page of type Page Menu.if u check this field and in the where condition of css list menu webpart i added the following condition

IsAdminpage in (0,{%currentuser.userisglobaladministrator%}).Now if user is not admnistrator then the condition is evalvated to

IsAdminpage in (0,0).so it will items with 0.

if current user is admin then the condition is evalvated to IsAdminpage in (0,1).so it will get all the records in database (bcoz the condition is 0 or 1);

It may help you in your case.

Thanks & Regards
Anjee




User avatar
Member
Member
vlatso-synqsolutions - 5/18/2010 1:06:30 PM
   
RE:Hide A page(menu Item) from menu if user Role is other than Admin.
Hmm, I would expect this to be a standard requirement and I wish it would be much easier to set.

1 2