设为首页 收藏本站
查看: 583|回复: 0

[经验分享] How to Create custom XMLSiteMapProvider and render it in SharePoint 2007 MOSS

[复制链接]

尚未签到

发表于 2015-9-29 10:16:09 | 显示全部楼层 |阅读模式
  原文链接:http://blogs.msdn.com/syedi/archive/2008/09/03/how-to-create-custom-xmlsitemapprovider-and-render-it-in-sharepoint-2007-moss.aspx
  
  All the OOB SiteMapProvider in MOSS are rendered through the delegate control through the control assembly. The OOB SiteMapProvider which are used in various site ranges in the MOSS are as follows : All the providers are self explanatory from their type name and their control class which renders is given beside :
  
  Microsoft.SharePoint.Navigation.SPNavigationProvider
  Microsoft.SharePoint.Navigation.SPSiteMapProvider
  Microsoft.SharePoint.Navigation.SPContentMapProvider
  Microsoft.Office.Server.Web.AdministrationQuickLaunchProvider
  Microsoft.Office.Server.Web.SharedServicesQuickLaunchProvider
  Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider (Note : The PortalSiteMapProvider can be rendered in 3 different navigation type : Global,Combined and current)
  Microsoft.SharePoint.Portal.WebControls.SiteDirectoryCategoryProvider
  Microsoft.SharePoint.Portal.MySiteMapProvider
  Microsoft.SharePoint.Portal.MySiteLeftNavProvider
  Microsoft.SharePoint.Portal.Analytics.UsagePagesSiteMapProvider
  
  
  These providers have been registered through different features as a delegate control and the datasource can be used through a delegate control “ID” while rendering the provider. These providers are registered in the web.config as well in the following manner.
  
  <siteMap defaultProvider="CurrentNavSiteMapProvider" enabled="true">
        <providers>
          <add name="SPNavigationProvider" type="Microsoft.SharePoint.Navigation.SPNavigationProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="SPSiteMapProvider" type="Microsoft.SharePoint.Navigation.SPSiteMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="SPContentMapProvider" type="Microsoft.SharePoint.Navigation.SPContentMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="SPXmlContentMapProvider" siteMapFile="_app_bin/layouts.sitemap" type="Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="AdministrationQuickLaunchProvider" description="QuickLaunch navigation provider for the central administration site" type="Microsoft.Office.Server.Web.AdministrationQuickLaunchProvider, Microsoft.Office.Server.UI, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="SharedServicesQuickLaunchProvider" description="QuickLaunch navigation provider for shared services administration sites" type="Microsoft.Office.Server.Web.SharedServicesQuickLaunchProvider, Microsoft.Office.Server.UI, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="GlobalNavSiteMapProvider" description="CMS provider for Global navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Global" EncodeOutput="true" />
          <add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Combined" EncodeOutput="true" />
          <add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" />
          <add name="CurrentNavSiteMapProviderNoEncode" description="CMS provider for Current navigation, no encoding of output" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="false" />
          <add name="SiteDirectoryCategoryProvider" description="Site Directory category provider" type="Microsoft.SharePoint.Portal.WebControls.SiteDirectoryCategoryProvider, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="MySiteMapProvider" description="MySite provider that returns areas and based on the current user context" type="Microsoft.SharePoint.Portal.MySiteMapProvider, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="MySiteLeftNavProvider" description="MySite Left Nav provider that returns areas and based on the current user context" type="Microsoft.SharePoint.Portal.MySiteLeftNavProvider, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
          <add name="UsagePagesSiteMapProvider" description="Provider for navigation in Portal Usage pages" type="Microsoft.SharePoint.Portal.Analytics.UsagePagesSiteMapProvider, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
        </providers>
      </siteMap>
  
  If you want to customize any of these providers to include or exclude any sitemap then you create a custom class inheriting the SiteMapProvider which you want to customize and can register it as a delegate control through feature. Of course need to make an entry for the custom provider in the web.config as well. Then you can use the custom provider to render your sitemap navigation.
  
  
  In the above shown provider entries in the web.config if you notice the highlighted part then you can find the SPXMLContentMapProvider which provides the sitemap for the layouts pages in the form &#8220;SiteMap&#8221; file.
  
  Based on this you can create your custom &#8220;SiteMap&#8221; file with your ASP.NET knowledge to render your custom sitemaps in the SharePoint. This blog post will walk you through the implementation of the custom SPXMLContentMapProvider for your custom Sitemap file.
  
  Step 1: Create a feature to register your custom sitemap provider as a delegate control
  
  The following code snippet shows the contents of &#8220;Elements.xml&#8221; file to register your custom site map provider as a delegate control :-
  
  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Control
      Id="CustomTopNavigationDataSource"
      Sequence="25"
      ControlClass="System.Web.UI.WebControls.SiteMapDataSource"
      ControlAssembly="System.Web, version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        
  //Create the properties for the ID and the name of the sitemapprovider. The ID and the name will be used to identify the sitemapprovider to render in the pages and to read the entries from the web.config.
        
      <Property Name="ID">CustomtopSiteMap</Property>
      <Property Name="SiteMapProvider">CommonLawSiteMapProvider</Property>
      <Property Name="ShowStartingNode">true</Property>
    </Control>
  </Elements>
  
  Step 2: Create your custom sitemap file, consider it is custom.sitemap and place it under the Layouts/1033
  
  Step 3: Make the site map provider entry in the web.config as follows :
  
  <add name="CommonLawSiteMapProvider" siteMapFile="_layouts/1033/custom.sitemap" type="Microsoft.SharePoint.Navigation.SPXmlContentMapProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  
  
  Just install and activate the feature which register your custom sitemap provider as a delegate control. Then use this delegate control &#8220;ID&#8221; and the name of the provider to render the sitemap provider in the master pages.
  
  One very important thing you can notice here is the path of the OOB sitemap file and the path of the custom sitemap file. The OOB sitemap file is in the &#8220;_app_bin&#8221; folder and the custom sitemap file is under the &#8220;_layouts/1033&#8221; folder.
  
  The reason is that the OOB &#8220;layouts.sitemap&#8221; file is used to render the sitemap for the layouts pages which can be accessed only by the certain privileged users and not by the least privileged users like Visitors or viewers. So keeping this file in the &#8220;_app_bin&#8221; folder doesn&#8217;t do any harm. But consider your custom sitemap file is used to provide the sitemap for all the pages in the site then regular visitor users with least privilege will not be able to find the file and will be getting the error message stating that the file required by the &#8220;XMLSiteMapProvider&#8221; doesn&#8217;t exist if the sitemap file is in the &#8220;_app_bin&#8221; folder. The admin users will not be encountering with this issue and the sitemap will be rendered fine but the least privilege users will be encountering this issue as they don&#8217;t have permission in the &#8220;_app_bin&#8221; folder. So either you can give permission to everyone in the &#8220;_app_bin&#8221; folder else you can keep your custom sitemap file in the &#8220;_layouts/1033&#8221; folder.
  
  Hope the second option on keeping the sitemap file under the &#8220;_layouts/1033&#8221; makes more sense than keeping the sitemap file in the &#8220;_app_bin&#8221; folder and giving the permission to everyone.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-120329-1-1.html 上篇帖子: SharePoint 权限提升(SPSecurity) 下篇帖子: 备份SharePoint站点的三种方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表