Subscribe:      
 

SharePoint Site Definition for Multiple Subsites Creation

Written By: Shishir Bhandari -- 4/26/2011 -- join -- contribute -- (1) comments -- printer friendly version

Rating: Rate --

Categories: Configurations, Design, MOSS 2007, SharePoint 2010, SharePoint Foundation 2010, WSS3

< Prev - 1 | 2 | 3 | - Next > | Become a paid author

Problem

The requirement of creating multiple SharePoint sub sites automatically, at one time, comes up at most organizations. You would think this would be really complex since it requires you to inherit SPWebProvisioningProvider, override its Provision function and do C# coding. This approach does involve a good amount of time and effort, but there is a better way which will save time writing code and will work seamlessly.


Solution

The solution lies in exploring the (out of the box ) Site Definition for Site Collection!

You must have noticed that a site collection provisions with its sub sites. For example: a Collaboration portal would come with sub sites for News and Search. A little bit of research on how it is done reveals the steps for creating a site definition which will create a site and its sub sites automatically.

To try our approach, let’s create a publishing site (BLANKINTERNET#0 site definition) with three sub sites namely:

    a. News Site using (SPSNEWS#0 site definition)
    b. Press Releases site (BLANKINTERNET#1 site definition)
    c. Team Site (STS#1 site definition)

To get the full list of site definition IDs, read here.

Follow the below steps:
    1) Go to 12 \Template\XML (MOSS 2007) Or 14\Template\XML (SharePoint 2010)

    2) Create an XML file (let’s say subwebs.xml). Open the file and paste the below text:

<?xml version="1.0" encoding="utf-8" ?>
<portal xmlns="PortalTemplate.xsd">

<!—Write you Custom site and subsite info here -->

    <web name="BlankInternet Site" 
         siteDefinition="BLANKINTERNET#0" 
        displayName="BlankInternet Site" 
        description="It has three subwebs" >
        <webs>
	  
            <web name="News site" 
               siteDefinition="SPSNEWS#0" 
              displayName="News site" 
              description="subweb 1" />

            <web name="Press Releases site" 
                 siteDefinition="BLANKINTERNET#1" 
                displayName="Press Releases site" 
                description="subweb 2" />

         
          <web name="Team site" 
               siteDefinition="STS#1" 
              displayName="Team site" 
              description="subweb 3" />

        </webs>

   </web>
</portal>

You can change the sitedefinition, displayName and description of the sites based on which sites you want to provision.

< Prev - 1 | 2 | 3 | - Next >



Learn more about SharePoint



Sponsor Information




Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners.


MSSharePointTips.com | MSSQLTips.com