我正在从silverlight webpart创建一个新的sharepoint站点 . 我正在使用ClientContext模型,它适用于团队网站模板(STS#0) . 我需要从我创建的CUSTOM站点模板创建一个新站点,但我不知道如何引用此模板来指定它是名称的Web模板,并且只能引用其中一个标准模板 .
这是我的代码:
string siteUrl = App.RootSite;
string siteDescription = project.projectName; // "A new project site.";
int projectLanguage = 1033;
string projectTitle = project.projectName; // "Project Web Site";
string projectUrl = project.projectURL; //"projectwebsite";
bool projectPermissions = false;
string webTemplate = "STS#0"; //TODO: reference custom site template
try
{
ClientContext clientContext = new ClientContext(siteUrl);
Web oWebsite = clientContext.Web;
WebCreationInformation webCreateInfo = new WebCreationInformation();
webCreateInfo.Description = siteDescription;
webCreateInfo.Language = projectLanguage;
webCreateInfo.Title = projectTitle;
webCreateInfo.Url = projectUrl;
webCreateInfo.UseSamePermissionsAsParentSite = projectPermissions;
webCreateInfo.WebTemplate = webTemplate;
oNewWebsite = oWebsite.Webs.Add(webCreateInfo);
clientContext.Load(
oNewWebsite,
website => website.ServerRelativeUrl,
website => website.Created,
website => website.Id);
clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFail);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
2 回答
遍历所有可用模板,您会发现自定义模板名称前面有guid: #ProjectSiteTemplate .
示例http://www.learningsharepoint.com/2010/07/25/programatically-create-site-from-site-template-sharepoint-2010/