Question

I am currently working on some SharePoint branding for the first time. I am using SharePoint Foundation 2010. I was trying to attempt to remove the quick-launch section from the page for everybody that is not inside the "Administrator" group. Now, I tried writing a feature or web part to do this with the following c# code:

SPWeb web = SPContext.GetContext(this.Context).Web.ParentWeb;
web.AllowUnsafeUpdates = true;
web.QuickLaunchEnabled = false;
web.Update();

This did not remove the actual panel itself and move the main content over to the left. I decided to attempt this from a Jquery route. My code is copied below. However, when I tried this in the master-page, the page fully loads, and then the panel is removed. I would like this to occur before the page actually loads so the user does not see the page popup and then change. I am not 100% sure that JQuery is the way to go, please help me as I am struggling with this.

$(document).ready(function(){
     $().SPServices({
     operation: "GetGroupCollectionFromUser",
     userLoginName: $().SPServices.SPGetCurrentUser(),
     async: false,
     completefunc: function(xData, Status) {
        if($(xData.responseXML).find("Group[Name='Administrator']").length == 1)
        {}
        else{

         var quicklaunchpanel = document.getElementById('s4-leftpanel');  
    quicklaunchpanel.style.display="none";
    var maincontent = document.getElementById('MSO_ContentTable');
    maincontent.style.cssText = "margin-left:0px;";

        }
      }

});

Note: I also tried $(document).load() and $('#s4-leftpanel').load() but neither of this caused any action what so ever.

TIA!

Was it helpful?

Solution 2

I was able to user the SPSecurityTrimmedControl to accomplish this:

I originally set the display property to s4-leftpanel to "none" and then had this block of code after this panel:

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="FullMask">
        <script type="text/javascript">
            document.getElementById("s4-leftpanel").style.display = "block";
        </script>
        </Sharepoint:SPSecurityTrimmedControl>

I also performaned the same for the margin of the MSO_ContentTable.I set it to 0px and then ran this code after that div:

        <Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="FullMask">
        <script type="text/javascript">
            document.getElementById("MSO_ContentTable").style.marginLeft = "155px";
        </script>
        </Sharepoint:SPSecurityTrimmedControl>

OTHER TIPS

Shenn,

Have you considered building a custom navigation control? It may sound radical, but might be what you're looking for.

Take a look at http://blogs.msdn.com/b/modonovan/archive/2008/05/30/custom-navigation-in-sharepoint-the-full-monty.aspx, especially options 5 and 6.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top