要求:具有自定义文档库的WebTemplate以及自定义内容类型以在线SharePoint 2013在线

创建了Web模板和内容类型,两者都在在线SharePoint中正常工作。但我面临着列表定义的两个主要问题

1)无法将自定义内容类型作为ContentTypere在列表定义架构中包含。 2)无法弄清楚如何将列表定义包含到Web模板的oneT.xml,我尝试将要素ID添加到,但在使用模板创建新站点时,缺少文档库。

代码:

oneT.xml

<?xml version="1.0" encoding="utf-8"?>
<Project Title="$Resources:onet_TeamWebSite;" Revision="3" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint" UIVersion="15" HideSiteContentsLink="true">
  <NavBars>
  </NavBars>
  <ListTemplates>
  </ListTemplates>
<Configurations>
    <Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/seattle.master">
      <Lists>
        <List FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Type="101" Title="$Resources:core,shareddocuments_Title_15;" Url="$Resources:core,shareddocuments_Folder;" OnQuickLaunch="TRUE" QuickLaunchHeading="TRUE" />
      </Lists>
      <SiteFeatures>
        <Feature ID="8b312a79-d117-44ef-81b2-453a71ccfea5" /> // Feature including the list definition
      </SiteFeatures>
      <WebFeatures>
      </WebFeatures>
    </Configuration>
  </Configurations>
  <ServerEmailFooter>$Resources:ServerEmailFooter;</ServerEmailFooter>
</Project>
.

列表定义的schema.xml的一部分

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Resources" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Resources" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
  <MetaData>
    <ContentTypes>
      <ContentType ID="0x010100992CB78E42804317A18A5E40907EA235" Name="Custom Content Type" Group="Custom Content Type" Description="Custom Content Type" Inherits="TRUE" Version="0">
        <FieldRefs>
          <FieldRef ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Name="Organization/Author" Required="TRUE" />
          <FieldRef ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Name="Publication Date" Required="TRUE" />
          <FieldRef ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Name="Partners" Required="TRUE" />
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields>
      </Fields>
    <Views>
.

在ContentTypes中,我也尝试使用ContentTyperef,但也没有工作

内容类型的元素.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Field ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Type="Text" Name="Organization/Author" DisplayName="Organization/Author" ShowInNewForm="FALSE" ShowInFileDlg="FALSE"></Field>
  <Field ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Type="DateTime" Name="Publication Date" DisplayName="Publication Date" Required="FALSE" EnforceUniqueValues="FALSE" ShowInNewForm="FALSE" ShowInFileDlg="FALSE"></Field>
  <Field ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Type="Choice" Name="Partners" DisplayName="Partners" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Dropdown" FillInChoice="FALSE">  
    <CHOICES>
      <CHOICE>Yes</CHOICE>
      <CHOICE>No</CHOICE>
    </CHOICES>
  </Field>

  <!-- Parent ContentType: Document (0x0101) -->
  <ContentType ID="0x010100992CB78E42804317A18A5E40907EA235" Name="Custom Content Type" Group="Custom Content Type" Description="Custom Content Type" Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{796E4A07-6AD2-4AC4-8788-2536EA0B0224}" Name="Organization/Author" Required="TRUE" />
      <FieldRef ID="{782D2071-7531-4F34-92E2-2418090A3ED9}" Name="Publication Date" Required="TRUE" />
      <FieldRef ID="{ceee0e58-7e36-47c9-9e20-3d3d0d7ba0d4}" Name="Partners" Required="TRUE" />
    </FieldRefs>
  </ContentType>
</Elements>
.

谁能建议我做错了什么?

还有更多的事情,所有三件事(webtemplate,内容类型和列表定义)包含在相同的特征中,该特征在于站点,因为我将把它部署到SharePoint在线,这是沙盒式架构。

有帮助吗?

解决方案

I'd like to suggest you restructure your code a bit if I may. Put the web template in its own solution. Get that working first.

Then create a second solution that includes the content type and list. Its feature should be scoped to Web, not Site. I don't see any issues with your schema, and VS2012 in any case has a list designer wizard, and if you used that you should be OK.

The reason I am suggesting 2 solutions is because web templates complicate the development workflow. Redeploying it entails deleting and recreating the whole site. There's no need to do that if you're only working on the list. With your list in a separate solution your redeployments will go much quicker.

If you need everything in one solution you can put them back togather once everything is working, but you need to have two features: Your web template must be in a Site-scoped feature, and your list needs to be in a Web-scoped feature. The fields and content type, I think, might be OK in either scope but I've always made them Web scoped.

许可以下: CC-BY-SA归因
scroll top