开发者

Replacement for Sharepoint's publishingWeb.currentNavigationNodes method?

I inherited a SharePoint 2007 site and I'm working on migrating it to SharePoint 2010. I'm recompiling feature receivers using the 2010 .DLLs and I ran into the following error:

'Microsoft.SharePoint.Publishing.PublishingWeb' does not contain a definition for 'CurrentNavigationNodes' and no extension method 'CurrentNavigationNodes' accepting a first argument of type 'Microsoft.SharePoint.Publishing.PublishingWeb' could be found (are you missing a using directive or an assembly reference?)

In Sharepoint 2007, CurrentNavigationNodes was a property of Microsoft.SharePoint.Publishing.PublishingWeb. Apparently that's moved to another class, or been replaced altogether with another way of getting a node list. I can't figure it out. Anyone know what the new way of doing this is?

Here's the relevant piece of 2007 code:

        // set references to site, web, publishing site, publishing web
        SPWeb thisWeb = (SPWeb)properties.Feature.Parent;
        SPSite thisSite = thisWeb.Site;
        PublishingSite thisPubSite = new PublishingSite(thisSite);
        PublishingWeb thisPubWeb = PublishingWeb.GetPublishingWeb(thisWeb);

        // enable tree view
        thisWeb.TreeViewEnabled = tru开发者_StackOverflowe;
        thisWeb.Update();


        // navigation settings
        thisPubWeb.InheritGlobalNavigation = true;
        thisPubWeb.InheritCurrentNavigation = false;
        thisPubWeb.IncludePagesInNavigation = true;
        thisPubWeb.IncludeSubSitesInNavigation = true;
        thisPubWeb.NavigationShowSiblings = false;


        // clear current navigation (thrice needed to get everything)
        SPNavigationNodeCollection navNodes = thisPubWeb.CurrentNavigationNodes;
        foreach (SPNavigationNode thisNavNode in navNodes)
        {
                navNodes.Delete(thisNavNode);
        }
        foreach (SPNavigationNode thisNavNode in navNodes)
        {
            navNodes.Delete(thisNavNode);
        }
        foreach (SPNavigationNode thisNavNode in navNodes)
        {
            navNodes.Delete(thisNavNode);
        }

        thisPubWeb.Update();


Problem solved. It appears that since PublishingWeb extends SPWeb, Microsoft removed CurrentNavigationNodes from PublishingWeb in favor of going through SPWeb.Navigation.CurrentNavigationNodes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜