以编程方式创建/维护SharePoint快速启动菜单的最佳方法 [英] Best way to programmatically create/maintain SharePoint Quick Launch menu

查看:68
本文介绍了以编程方式创建/维护SharePoint快速启动菜单的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We have a solution that deploys a number of lists and pages. We wan't to create links for them on the Quick Launch menu automatically when a feature is activated.

结构可能是这样的.

  • 客户
    • 活动
    • 无效
    • Customers
      • Active
      • Inactive
      • 行情
      • 订单

      以此类推.网站集管理员可能会在活动"和非活动"链接之间添加另一个链接.禁用该功能后,我不想删除这些项目,但是如果再次激活该功能,我不想再次添加导航:)

      And so on. The site collection admin might add another link between the "Active" and "Inactive" links. When the feature is deactivated I don't want to remove the items, but if the feature is activated again i don't want the navigation to be added again :)

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

      Is there a built in API that you can use? I know about the SPWeb.Navigation.QuickLaunch and the SPNavigationNode(Collection) structure etc. But is there another way?

      希望您可以提供帮助:)

      Hope you can help :)

      推荐答案

      您还会寻找哪种其他方式?

      What kind of other way would you be looking for?

          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);
              }
          }
      

      我们使用上面的方法已经有一段时间了,而且效果还不错.

      We have used the method above for a while and it tends to work out just fine.

      如果您可以让我知道您要完成那种操作SPWeb的事情,Navigation不会允许您这样做,那么我也许可以为您提供更多帮助

      If you can let me know what kind of thing you are trying to accomplish that manipulating SPWeb.Navigation wont let you do, I might be able to be of some more help

      这篇关于以编程方式创建/维护SharePoint快速启动菜单的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆