Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top Navigation Bar

Status
Not open for further replies.

gillesnebel

Programmer
Mar 22, 2005
13
0
0
CH
I'm looking for third-party tool (or helpful tip) to remove top menu items like "Create", "Site Settings" depending of the logged in user, because it's very confusing for clients accessing this site. But as administrator all the items must be visible.

Can somebody help me,.... thx
 
Hi Gillesnebel,

You could write a webpart that only shows the links to certain people.

Code:
SPSite SiteCollection = new SPSite(<servername>);
SPWeb Web = SiteCollection.OpenWeb();
SiteCollection.CatchAccessDeniedException = false; //optional
try 
{
text += "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
if (Web.Permissions.DoesUserHavePermissions(SPRights.AddListItems) == true && Web.Permissions.DoesUserHavePermissions(SPRights.EditListItems) == true && Web.Permissions.DoesUserHavePermissions(SPRights.DeleteListItems)== true)
{
text += "<tr><td><a href=\"documenten/forms/allitems.aspx\">Document Managment</a></td></tr>";
text += "<tr><td><a href=\"Images/forms/allitems.aspx\">Image Management</a></td></tr>"; //paths are ofcourse diffrent for you!
}
if (Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) == true)
{	
text += "<tr><td><b>The Top nav Links</b></td></tr>";
text += "<tr><td><a href=\"_layouts/1043/settings.aspx\">Site Settings</a></td></tr>";
text += "<tr><td><a href=\"_layouts/1043/create.aspx\">Create</a></td></tr>";
text += "<tr><td><a href=\"_layouts/1043/viewlsts.aspx\">Documents and Lists</a></td></tr>";
text += "<tr><td><a href=\"javascript:HelpWindowKey(%22NavBarHelpHome%22)\">Help</a></td></tr>";
}
text += "</table>";
				
if (Web.Permissions.DoesUserHavePermissions(SPRights.ManageWeb) == true)
{	
text+= "<script type=\"text/javascript\">";
text+= "document.getElementById('hidediv').style.visibility = 'visible';";
text+= "</script>";
//i have put the menu for editing a page in a <div id="hidediv" style="visibility: hidden"></div> tag this code above makes it visible for an administrator. !The webpart has to be below the edit menu for this to word.
}

}
catch( Exception exp ) {
text += exp.Message;
}

	RenderChildren(output);
	output.Write(text);
}

I hope ive help you a bit, goodluck!

Greetings from ChaserNL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top