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?

Gaurravs
  • 3,558
  • 12
  • 22
  • 33
  • 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 Jul 19 '16 at 10:41
  • you can check edit mode but it only covers adding webparts I guess, http://sharepoint.stackexchange.com/questions/12792/how-do-i-know-if-the-page-is-in-edit-mode-from-javascript – Tiago Duarte Jul 19 '16 at 10:53
  • @TiagoDuarte I am more worried about editing/removing existing webparts as well. You think this will work with it? – Gaurravs Jul 19 '16 at 11:04
  • @garglblarg Can we do it group specific instead of user specific? – Gaurravs Jul 19 '16 at 11:06
  • @Gaurravs i guess so, see this thread regarding group membership checking: http://stackoverflow.com/a/22126724/2608528 – garglblarg Jul 19 '16 at 11:15
  • @garglblarg thanks for the help.. Tiago's approach worked easily. – Gaurravs Jul 19 '16 at 11:57

1 Answers1

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>
Tiago Duarte
  • 5,477
  • 2
  • 21
  • 43