Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have designed the quick launch for a SharePoint 2010 site in master page, Now for some pages I do not want the quick launch to show up, (Or better say some SharePoint groups).

So I added a web part with the following code to hide the Quick launch for that pages,

<style>
#s4-leftpanel{
display:none
}
.s4-ca{
margin-left:0px
}
</style>

Now the problem is , if the page loads too slow the master page will show the quick Launch, till the web part executes, and the users can see or even click the links in the quick launch, that they are not supposed to see..

How can I get rid of this problem?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

You dont have to use code behind if you could use SPServices Jquery from CodePlex.

Do the necessary steps:

  1. Download the jquery.SPServices-0.6.2.js from SPServices Jquery.

  2. Upload the minnified js file - 'jquery.SPServices-0.6.2.min.js' to the style library of your site.

  3. Add the script link <script type="text/javascript" src="Path of the JS file"> </script> to the master page.

  4. Add the following code

    var groupName; $().SPServices({ operation: "GetGroupCollectionFromUser", userLoginName: $().SPServices.SPGetCurrentUser(), async: false, completefunc: function(xData, Status) { alert(xData.responseXML.xml); $(xData.responseXML).find("[nodeName=Group]").each(function() {
    groupName = $(this).attr("Name"); }); } });

  5. Now, you have the group name in the variable groupName. Put an 'If' condition to check whether it matches your logic and then add the code to disable the quick launch.

This also should eliminate your need of even adding web part on each pages as this piece of code sits in the master page.

share|improve this answer
    
Thank you for this detail info +1. How ever I guess I should go for Daniel's method, since we can do it with out any J script. –  Jithu Dec 5 '11 at 8:12
    
Hi Deepu how can I write the code, QuickLaunchNavigationManager.Visible = false; inside the if condition, I am trying to hide it !! –  Jithu Dec 6 '11 at 5:28
    
var groupName; $().SPServices({ operation: "GetGroupCollectionFromUser", userLoginName: $().SPServices.SPGetCurrentUser(), async: false, completefunc: function(xData, Status) { alert(xData.responseXML.xml); $(xData.responseXML).find("[nodeName=Group]").each(function() { groupName = $(this).attr("Name"); }); } }); if($.trim(groupName) != 'Ms Presales') { QuickLaunchNavigationManager.Visible = false; } This is the one I wrote, Doesn't Seem to be working !! –  Jithu Dec 6 '11 at 5:40
    
Paste this code after the PlaceHolderMain contentplaceholder var groupName; $().SPServices({ operation: "GetGroupCollectionFromUser", userLoginName: $().SPServices.SPGetCurrentUser(), async: false, completefunc: function(xData, Status) { $(xData.responseXML).find("[nodeName=Group]").each(function() {groupName = $(this).attr("Name");}); } }); if($.trim(groupName) != 'Ms Presales') {document.getElementById('s4-leftpanel').style.display = 'none'; } Please make sure the groupname is correct. :) –  Deepu Nair Dec 6 '11 at 6:33
    
Getting an error Message: 'jQuery' is undefined Line: 20 Char: 1 Code: 0 URI: sok:1234/Scripts/jquery.SPServices-0.7.0.js –  Jithu Dec 6 '11 at 7:37
show 5 more comments

Use codebehind in the master page to check if the current user is a member of the group (or not), then use the Visible property on the Quick Launch web control to hide it.

Control:

<Sharepoint:SPNavigationManager
            id="QuickLaunchNavigationManager"
            runat="server" ...

Code behind (eg on Page_Load)

QuickLaunchNavigationManager.Visible = false;
share|improve this answer
    
Thanks Daniel, You made my day :) –  Jithu Dec 5 '11 at 8:13
    
Hi Dan, One quick doubt, I was editing the master page in Share Designer 2010, then how can I add a code behind to this master page ? –  Jithu Dec 6 '11 at 4:43
    
You will need to build the code behind in Visual Studio, create a class which inherits from MasterPage, then inherit from your class in the masterpage file. Deploy the .dll using a WSP. You can still edit the masterpage in SharePoint Designer, but it is attached to the codebehind as it now inherits your class, instead of the default. –  Daniel Butler Dec 6 '11 at 6:26
add comment

not necessary to modify your Master page code behind, you can use DelegateControl: http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html

share|improve this answer
    
Thanks Ivan, Let me check it as I am not too good with Delegate Control!! –  Jithu Dec 6 '11 at 4:42
add comment

other way to do it is to wrap QuickLaunch layout in your master in SecurityTrimmedControl

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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