3

I created a WebTemplate in Visual Studio and deployed it as a farm solution (I couldn't create a sandbox solution because it needs to deploy a custom master page and other stuff to the GAC). Now it shows up both in Central Admin, on the create site collection page and within existing site collections, on the Create a site page. I want it to be available only when creating sub-sites; I don't want it to be used for a root site.

Is this possible? How?

UPDATE:

as per Naim's answer, I tried adding SubWebOnly="TRUE" in the ONET.XML inside the <Configuration> tag, but the template still shows up in Central Admin Create site collection page

1 Answer 1

5

Go to your Web Template File inside …/TEMPLATE/LCID/XML

There is an attribute SubWebOnly in the Configuration element of the template. Set that attribute to TRUE and the template should show only when creating subsites.

<Template Name=" " ID="">
    <Configuration ID=""
               Title=""
               ...
               ...   
               SubWebOnly = "TRUE" 
               >
</Configuration>

5
  • How can I do this in Visual Studio directly? I don't want to force users of my WebTemplate to manually edit the configuration after that it is has been deployed. Also, the WebTemplate is deployed by a farm feature
    – MdMazzotti
    Commented Jan 15, 2014 at 10:41
  • You have your web template in Visual Studio right? In the web template file (mapped folder to .../TEMPLATE/1033/XML) add SubWebOnly attribute to the configuration element. Users don't have to change it, it will be in the SharePoint Root folder when you install your feature. Commented Jan 15, 2014 at 10:47
  • I don't have the mapped folder. The template elements.xml and onet.xml files deploy to {SharePointRoot}\Template\Features\{FeatureName}\MyTemplateName\
    – MdMazzotti
    Commented Jan 15, 2014 at 10:50
  • This works with custom site definitions but It’s possible to not work with WebTemplate. In your WebTemplate element you use OOB site definition in BaseTemplateName, BaseTemplateID and BaseConfigurationID . That OOB site definition has SubWebOnly false by default. Two things you can try: 1. Use SubWeb=”TRUE” in the WebTemplate element (MSDN is not very clear what this attribute's purpose). Or 2.Create a simple site definition,in its <Configuration> element set SubWebOnly=”TRUE”. Then in WebTemplate element set BaseConfigurationID to this new site definition. Let us know if you got it working. Commented Jan 15, 2014 at 21:33
  • Last option is to go with custom site definition altogether. Each has its pros and cons. Check this article. Commented Jan 15, 2014 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.