Today I was faced with an interesting project. I have some external users of the Intranet site I am working on that need to only see one list of items on the Intranet site. What makes this tricky is that I have customized the Quick Launch navigation so that every link (and even the headings) are custom, which means SharePoint will not security trim them.
I began searching for ways to hide items in the Quick Launch when I came across a post by
Todd Baginski that talked about programmatically adding and removing items from the Quick Launch menu. I followed down the article and found the SPNavigationNode object and decided to search the MSDN for that class. I found a property called IsVisible that allows you to set whether the Menu Item is visible or not. Great!! I thought. This is exactly what I need to hide these items for this external group of users. I added the lines of code to set the property:
menuItem.IsVisible = False
menuItem.Update()
web.Update()
When changing the properties for items such as Menu Items, List Items, or Lists, you should always call the Update method to update the properties. I called the SPWeb.Update method for good measure to make sure that the menu item was updated.
Ran the page and guess what, the menu item was still there. So I checked further into the Internet and found a some people that agreed that the property does not work. So I submitted a question on the MSDN forums and will see if this is a Microsoft bug and if there is a fix for it.
As for the way I finally decided to hide the menu items is a little bit of a hack. For now I am hiding the entire Quick Launch menu and displaying a custom link that I created just for that group of users. I call this a hack because I had to work around that property bug and because I will need to edit the master page and create a new link from hand any time that group of users needs to see another item in the site.
Labels: IsVisible bug, SPNavigationNode.IsVisible Property