Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a site definition but i need to limit what sub sites can be created by the user.

How can I do this with SharePoint 2010?

thanks

share|improve this question
    
We are not using the publishing feature. How can we limit the list of templates that are listed for creating sub sites? –  dave Oct 27 '10 at 17:26
add comment

2 Answers 2

As part of the publishing features you can add AvailableWebTemplates and AvailablePageLayouts declaratively as feature properties in onet.xml:

<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">    <!-- Publishing -->    <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
...
<Property Key="AvailableWebTemplates" Value="*-BLANKINTERNET#1;*-BLANKINTERNET#2"/>
<Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/ArticleLeft.aspx:~SiteCollection/_catalogs/masterpage/ArticleLinks.aspx:~SiteCollection/_catalogs/masterpage/ArticleRight.aspx"/>
...
</Properties>
</Feature>

The * can be replaced with a specific LCID (eg 1033) if you only want the template available for specific languages. Seperator is ; for templates and : for page layouts

share|improve this answer
    
Can this be done without turning on the publishing features? –  dave Oct 27 '10 at 17:23
    
SPWeb.SetAvailableWebTemplates() is what you are looking for. Filter on LCID to only allow templates for specific languages. Also remember to call update on SPweb after setting the allowed templates. msdn.microsoft.com/en-us/library/ms435526.aspx –  Anders Rask Oct 29 '10 at 22:13
add comment

I would like to know if there is a declarative way to do it. But you can have a feature activtaed which receives following event whenever a new web is being created. You will have an opportunity to check for allowed templates and then redirect the users to error page if needed.

public override void WebAdding(SPWebEventProperties properties) { // Check properties.Web.WebTemplate belongs to the allowed templates... and if not do following

properties.Cancel = true; properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl; properties.RedirectUrl = "/_layouts/Custom/error.aspx"; }

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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