代码之家  ›  专栏  ›  技术社区  ›  zekus

SharePoint表单库:通过编程或Stsadm命令将内容类型更改为自定义表单模板

  •  1
  • zekus  · 技术社区  · 17 年前

    我有一个自定义站点定义,其中包括一个表单库。我在InfoPath中创建了一个表单模板。通过SharePoint功能,我可以部署所有内容,但我无法确定如何将表单库的默认表单更改为指向我在InfoPath中创建的表单。我有一个部署表单的功能非常好,但我必须手动进入表单库的高级设置,允许内容类型管理,将默认内容类型更改为模板,并删除默认内容类型。

    任何关于如何以编程方式或通过stsadm实现这一点的想法都将不胜感激!

    科尔比非洲

    1 回复  |  直到 17 年前
        1
  •  1
  •   Nat    17 年前

    下面是我用来设置列表内容类型的一些代码。

     void AddContentTypes(SPWeb web)
        {
            //get a reference to content types previously installed
            SPContentType CompanyAContentPage = web.AvailableContentTypes["CompanyA Content Page"];
            SPContentType CompanyAWelcomePage = web.AvailableContentTypes["CompanyA Welcome Page"];
    
            //get list to mess with
            SPList spList = web.Lists["Pages"];
    
            //enable management of content types
            spList.ContentTypesEnabled = true;
    
            //get the content types added to the list (different from the web ones)
            SPContentType newCompanyAPageContentType = spList.ContentTypes.Add(CompanyAContentPage);
            SPContentType newCompanyAWelcomePageContentType = spList.ContentTypes.Add(CompanyAWelcomePage);
            //update list
            spList.Update();
    
            //get a list of content types for the "new" drop down on the list
            List<SPContentType> contentTypeList = new List<SPContentType>();
            contentTypeList.Add(newCompanyAPageContentType);
            contentTypeList.Add(newCompanyAWelcomePageContentType);
    
            //set the content types for the "new" drop down list
            spList.RootFolder.UniqueContentTypeOrder = contentTypeList;
            spList.RootFolder.Update();
        }
    

    和你的问题不完全一样,但我希望它能有所帮助。