I'm creating a tool that will "clone" webs inside a site. It reads child webs of a set web and displays them as templates for the user to select from. I've however run into a problem when I try to create new webs using the template name and id gotten from the existing webs.
I'm using the following code to get the template name (of the form: STS#0):
//web is an SPWeb instance
var templateName = web.WebTemplate + "#" + web.WebTemplateId;
I've created three "template" webs using the standard sharepoint tool:
+--------------+-------------------------+------------------+
| Type | SharePoint TemplateName | My TemplateName |
+--------------+-------------------------+------------------+
| Team Site | STS#0 | STS#1 |
| Blog | BLOG#0 | BLOG#9 |
| Project Site | PROJECTSITE#0 | PROJECTSITE#6115 |
+--------------+-------------------------+------------------+
The SharePoint template name is what I've gotten from the available templates list using this code (PowerShell or LINQPad):
Get-SPWebTemplate -CompatibilityLevel 15 |? {$_.LocaleId -eq 1033}
web.GetAvailableWebTemplates(1033).Cast<SPWebTemplate>().Select(template => new {Name = template.Name, Title = template.Title}).Dump(1);
Shows that the template names i get correspond to thesse:
+------------------+---------------+
| Type | What is it |
+------------------+---------------+
| STS#1 | Blank Site |
| BLOG#9 | Doesn't exist |
| PROJECTSITE#6115 | Doesn't exist |
+------------------+---------------+
What is going on and how can I get the correct template names (name#id form)?