locked
how to restrict subsite creation using webtemplate RRS feed

  • Question

  • Hi,

    I have created a web template in Sharepoint 2010 and deployed it using a farm feature.

    As a result, I can create site collections using this template as well as sub sites.

    I do not wish to allow creation of sub sites.

    In site definition’s web temp files, an attribute “RootWebOnly=TRUE” can be set, which dis-allows the creation of subsites.

    Therefore, the template does not appear for subsite creation.

    How can the sub site creation in web templates be dis-allowed?

    Any help is highly appreciated.

    Thx

    Monday, December 31, 2012 1:25 PM

All replies

  • Hi Nikhil,
    I believe there is no option directly in site definition to stop subsite creation.

    You can try creating site event receiver. Every time when a site is about to create this event will be fired. In the event receiver code check if the new website is under your custom definition site collection, cancel the operation and raise an error message that subsites are not allowed under this site collection.

    Hope this helps.

    Warm Regards,
    Adi
    www.adicodes.com
    • Proposed as answer by Srinu Tamada Wednesday, January 2, 2013 9:18 AM
    • Unproposed as answer by Bjoern H Rapp Monday, January 7, 2013 10:26 PM
    Monday, December 31, 2012 3:51 PM
  • you can hide the template from the list of avilable templates on http://sitepath/_Layouts/AreaTemplateSettings.aspx

    Site Settings --> Page layouts and site templates --> hide the template which should not be used to create subsite.

    Tuesday, January 1, 2013 10:54 AM
  • With AreaTemplateSettings we cannot deselect/hide all the site templates. At least one site template should be there.

    So,there is no way we can restrict complete subsite creation under particular site with AreaTemplateSettings. 

    Regards,
    Adi
    www.adicodes.com

    Wednesday, January 2, 2013 1:21 AM
  • I believe you dont have any option of hiding it using webtemplate, but if you have publishing feature enable on the site you can still achieve the way prachi suggested if thats fine with you.

    To set which site templates (and page layouts) are available for creating subsites and pages. You can do this via the Site Collection Site Settings page (Site Settings -> Page Layout and Site Template Settings). 

    The other option is to user stasadm command to hide them, this might help or give an idea for you to achieve your requirement

    http://blog.falchionconsulting.com/index.php/2007/08/set-available-site-templates/


    Raghavendra Shanbhag | Blog: www.SharePointColumn.com
    Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
    Disclaimer: This posting is provided "AS IS" with no warranties.

    Wednesday, January 2, 2013 4:49 AM
  • Hi,

    Having such unique requirement needs some unique way to tackle. I suggest you to create a WebProvisioned Event Receiver.

    In that Webprovisioned overrride method, first chech whether the current site is not RootWeb 

    if(!web.IsRootWeb)

    Is true, then in this method do nothing i.e. you are not assigning any master page or custom master page or no navigation or else you can redirect this to custom error page showing that this page cannot be created.

    Else.

    // Do whatever you please.

    I hope this approach might help you.

    Here is a reference link : http://blog.qumsieh.ca/2010/10/07/how-to-attach-an-event-receiver-to-the-web-added-event-and-for-what-purpose/

    let me know if this helps


    Thanks, Ali Yasir

    • Proposed as answer by Srinu Tamada Wednesday, January 2, 2013 9:18 AM
    • Unproposed as answer by Bjoern H Rapp Monday, January 7, 2013 10:25 PM
    Wednesday, January 2, 2013 5:10 AM
  • Hi All,

    Thanks for your inputs.

    But what I basically wanted is a little different.

    I have created a web template and deployed it using a farm scoped feature.

    So my web template is available in central admin for creation of site collections.

     

    However, the same template is available for sub site creation also –

    I do not want to create sub sites with the template I have created. Hence it should not be displayed in the sub site creation list.

    Is there a way to dis-allow the web template from appearing in sub-site “Create” page?


    • Edited by nikhil j1 Wednesday, January 2, 2013 10:44 AM
    Wednesday, January 2, 2013 10:44 AM
  • To be more specific . No you cannot do it from web template.

    Raghavendra Shanbhag | Blog: www.SharePointColumn.com
    Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
    Disclaimer: This posting is provided "AS IS" with no warranties.

    Wednesday, January 2, 2013 11:22 AM
  • Hi Nikihl,

    There is not straight forward way to hide the template from selection. To get more details on any alternatives available i request you to contact Microsoft Professional Support 

    Thanks,
    Raghav
    Wednesday, January 30, 2013 10:04 AM
  • You created a custom web template right? Cant u use the subweb boolean in the elements file of the webtemplate to control if it is shown or not?

    http://msdn.microsoft.com/en-us/library/ff408392.aspx

    Tuesday, June 11, 2013 10:43 AM