2010-07-29 44 views
1

使用SharePoint 2010和Visual Studio我已经创建了一个站点定义(从发布站点继承),它可以正确创建所有必需的列表,并且现在在“页面”文档库中包含页面实例。使用SiteDefinition将内容类型添加到列表中

的网页使用正确的自定义页面布局和正确的内容类型,然而,因为“页面”库默认情况下只接受第,空白和欢迎页它不知道我的自定义内容类型,因此页面没有按预期工作。

我试过在“List Added”事件中添加一个EventListener,没有成功,调试在我的断点处甚至没有中断,我也尝试了List Adding,List Item和Site Provisioned事件。这些似乎都不以我想要的方式工作。

我在下面的网站定义中包含了XML,如何将我的自定义内容类型添加到页面库中,因此我不必手动添加它?

<?xml version="1.0" encoding="utf-8"?> 
<Project Title="Custom_Site_Definition" Revision="2" ListDir="" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/"> 
    <NavBars> 
    <NavBar Name="SharePoint Top Navbar" Url="/Site Template" ID="1002" /> 
<!-- removed --> 
    </NavBars> 
    <Configurations> 
    <Configuration ID="0" Name="Custom_Site_Definition"> 
     <Lists /> 
     <WebFeatures> 
     <!-- Include the common WSSListTemplateFeatures used by CMS --> 
     <Feature ID="00BFEA71-DE22-43B2-A848-C05709900100" > </Feature> 
     <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101" > </Feature> 
     <Feature ID="00BFEA71-52D4-45B3-B544-B1C71B620109" > </Feature> 
     <Feature ID="00BFEA71-A83E-497E-9BA0-7A5C597D0107" > </Feature> 
     <Feature ID="00BFEA71-4EA5-48D4-A4AD-305CF7030140" > </Feature> 
     <Feature ID="00BFEA71-F600-43F6-A895-40C0DE7B0117" > </Feature> 

     <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"> 
     </Feature> 



     <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416"> 
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/"> 
      <Property Key="ChromeMasterUrl" Value=""/> 
      <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/at-a-glance.aspx"/> 
      <Property Key="PagesListUrl" Value=""/> 
      <Property Key="AvailableWebTemplates" Value=""/> 
      <Property Key="AvailablePageLayouts" Value=""/> 
      <Property Key="SimplePublishing" Value="true" /> 
      </Properties> 
     </Feature> 
     <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA"> 
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/"> 
      <Property Key="InheritGlobalNavigation" Value="true"/> 
      <Property Key="ShowSiblings" Value="true"/> 
      <Property Key="IncludeSubSites" Value="true"/> 
      </Properties> 
     </Feature> 
     <Feature ID="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB"> 
      <!-- Office SharePoint Server Publishing --> 
     </Feature> 
     </WebFeatures> 
     <Modules> 
     <Module Name="Home" /> 
     </Modules> 
    </Configuration> 
    </Configurations> 
    <Modules> 
    <Module Name="Home" Url="$Resources:osrvcore,List_Pages_UrlName;" Path=""> 
     <File Url="at-a-glance.aspx" Type="GhostableInLibrary" Level="Draft" > 
     <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Custom Article Page.aspx, $Resources:cmscore,PageLayout_WelcomeLinks_Title;" /> 
     </File> 
<!-- removed --> 
    </Module> 
    </Modules> 
</Project> 

回答

3

没关系,我知道了......最终

的解决办法是

  1. 一个特征添加到网站定义项目,在其Elements.xml文件
以下
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
    <ContentTypeBinding ContentTypeId="0x010100899F73B9F6814EA9AED9876985F28B39" ListUrl="Pages" /> 
</Elements> 

然后在Onet.xml文件添加一个功能依赖

<!-- Binds custom content types to Pages library.--> 
<Feature ID="8290db1f-0a87-44f3-be22-28c61f9c8965"> 
</Feature> 

最后一个模块在文件的最后添加的每一页(包括内容类型)

<File Url="at-a-glance.aspx" Type="GhostableInLibrary" Level="Draft" > 
     <Property Name="Title" Value="At a glance" /> 
     <Property Name="ContentType" Value="Custom_ContentTypes_Publishing - CustomFive" /> 
     <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Custom Article Page.aspx, $Resources:cmscore,PageLayout_WelcomeLinks_Title;" /> 
</File> 
+0

我总是忘了ContentTypeBinding功能。感谢您回复您自己的帖子并提供有价值的反馈。 – 2011-04-28 13:34:41