3

The SPNavigation property IsVisible only returns true. I have seen a lot of posts on the net stating the same thing. I know there is a way of hiding the nodes in MOSS using the PublishingWeb class, the problem I have is that we are using WSS which does not have microsoft.sharepoint.publishing.dll.

Is there a way of hiding navigation nodes in WSS dynamically?

1

Not without writing your own sitemapprovider. I once tried setting the same properties using a WSS site that MOSS uses in it's navigation, including BlankUrl (header) and Target (open in a new window) but they didn't work because the wss sitemapprovider doesn't pass those properties when it converts the node from a SPNavigationNode to a SiteMapNode. I ended up writing my own sitemapprovider that reads the spnavigationnodecollection and passes the properties through. Here's a snippet of my code:

protected SiteMapNode SPNavigationNodeToSiteMapNode(SPNavigationNode spNode, SPWeb web)
{
    if (spNode == null) return null;

    SiteMapNode node = NewSiteMapNode("sid:" + spNode.Id.ToString(),
    								  spNode.Url,
    								  spNode.Title,
    								  web.ServerRelativeUrl.ToLower());
    if (spNode.Id == ROOT_ID ||
    	spNode.Id == ALT_ROOT_ID)
    {
    	node.Url = "sid:" + spNode.Id.ToString();
    }

    if (!string.IsNullOrEmpty((string)spNode.Properties["BlankUrl"]))
    {
    	node.Url = string.Empty;
    }

    foreach (object key in spNode.Properties.Keys)
    {
    	switch (key.ToString())
    	{
    		case "Title": break;
    		case "ID": break;
    		case "ToolTip": break;
    		case "Expanded": break;
    		case "NavigateUrl": break;
    		default:
    			node[key.ToString()] = spNode.Properties[key].ToString();
    			break;
    	}
    }

    return node;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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