Programmatically Add Site Template (.stp) to SharePoint

岁酱吖の 提交于 2019-12-11 06:05:50

问题


I would like to programmatically add a custom site template (.stp file) to a MOSS team site collection as part of my build process. Can anyone point me towards the best way to do this?

Thanks, MagicAndi.


回答1:


A way of doing this with a feature would be to use the File element. STP files live in /_catalogs/wt so this type of feature will upload the file.

Update: More details in Create Feature to Upload Site Template File (.stp) in MOSS but for completeness here is the elements.xml:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="TeamSiteTemplate" List="111" Url="_catalogs/wt">
        <File Url="TeamSiteTemplate.stp" Type="GhostableInLibrary">
            <Property Name="LanguageDisplay" Value="English" />
            <Property Name="Version" Value="3" />
        </File>
    </Module>
</Elements>



回答2:


It looks like a simple batch file calling the STSADM tool with the -AddTemplate parameter is one option for this. The command is:

stsadm -o addtemplate -filename c:\template.stp -title "Template Title" -description "Template Description"

You can also delete an existing template using the command:

stsadm -o deletetemplate -title "Template title" 

See this article for further details




回答3:


to be more accurate: "stsadm -o addtemplate" adds the site template in the "central template gallery" not to a specific MOSS team site collection i.e. in the "site collection template gallery"; I think this can be a relevant difference in some (large) environment where could be advisable narrow the available template per sitecollection.

Installing application templates for Windows SharePoint Services 3.0



来源:https://stackoverflow.com/questions/1530806/programmatically-add-site-template-stp-to-sharepoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!