以编程方式创建/维护SharePoint Quick Launch菜单的最佳方法

Chr*_*rre 2 navigation sharepoint sharepoint-2010

我们有一个部署了许多列表和页面的解决方案.激活功能时,我们不会在"快速启动"菜单上自动为它们创建链接.

结构可能是这样的.

  • 顾客
    • 活性
    • 待用
  • 销售
    • 行情
    • 命令

等等.网站集管理员可能会在"活动"和"非活动"链接之间添加另一个链接.当该功能被停用时,我不想删除这些项目,但如果再次激活该功能,我不希望再次添加导航:)

是否有可以使用的内置API?我知道SPWeb.Navigation.QuickLaunch和SPNavigationNode(Collection)结构等.但还有另外一种方法吗?

希望你能帮忙:)

小智 5

你会寻找什么样的其他方式?

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWeb web = (SPWeb)properties.Feature.Parent; 

    // Check for an existing link to the list.
        SPNavigationNode listNode = web.Navigation.GetNodeByUrl(list.DefaultViewUrl); 

    // No link, so create one.
        if (listNode == null)
        {     
              // Create the node.
              listNode = new SPNavigationNode(list.Title, list.DefaultViewUrl);
              // Add it to Quick Launch.
              web.Navigation.AddToQuickLaunch(listNode, SPQuickLaunchHeading.Lists);
        }
    }
Run Code Online (Sandbox Code Playgroud)

我们已经使用了上面的方法一段时间,它往往很好.

如果你能让我知道你想要实现什么样的东西来操纵SPWeb.Navigation不会让你这么做,我可能会有更多的帮助