2

I am developing master page. I don't want to show top ribbon and left navigation menu to user.

So I am hiding it using css

#s4-leftpanel,#s4-ribbonrow {
 display:none !important;
}

The challenge I am facing is if I keep this css in master page. I am not able to create pages easily. Also not able to access ribbon.

So I created master page with both visible and created a page layout based on master page. and added this css to it. But again the same problem.

I need to make sure I can add webparts to any pages I create using the ribbon and access the left navigation. but not the users.

Any Suggestions?

6
  • well, you could add a little bit of javascript at the bottom of the master page to display the ribbon and leftpanel if the current user is some administrative account? something like if(_spPageContextInfo.userLoginName == "<adminLoginNamehere>"){$("#s4-ribbonrow).show();} maybe
    – garglblarg
    Commented Jul 19, 2016 at 10:41
  • you can check edit mode but it only covers adding webparts I guess, sharepoint.stackexchange.com/questions/12792/… Commented Jul 19, 2016 at 10:53
  • @TiagoDuarte I am more worried about editing/removing existing webparts as well. You think this will work with it?
    – Gaurravs
    Commented Jul 19, 2016 at 11:04
  • @garglblarg Can we do it group specific instead of user specific?
    – Gaurravs
    Commented Jul 19, 2016 at 11:06
  • @Gaurravs i guess so, see this thread regarding group membership checking: stackoverflow.com/a/22126724/2608528
    – garglblarg
    Commented Jul 19, 2016 at 11:15

1 Answer 1

4

You can try to validate if the page is in edit mode.

But since you'd rather be able to still see everything as an elevated user, perhaps using SPSecurityTrimmedControl is a better choice.

<style>
/*hide stuff from users*/
#s4-leftpanel,#s4-ribbonrow {
 display:none !important;
}
</style>

<Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="FullMask">
<style>
/*show stuff for full control users*/
#s4-leftpanel,#s4-ribbonrow {
block !important;
}
</style>
</Sharepoint:SPSecurityTrimmedControl>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.