Intro:
SharePoint is a great product to use, if you know how to leverage it properly. Thousands of companies out there that use SharePoint sadly miss out on some of the great quirks that SharePoint has to offer. One of my favourite ones is the ability to generate an entire portal structure on the fly. Not only does this save you time in the painstaking process of making sites and subsites (and assigning the right templates to them), but it also provides a clean structure which you can revisit at any time for restructuring or redesign purposes with little effort.
Step 1: Design it.
Do a high-level design of your portal’s structure based on what you (or client) needs, list all your main sites, and the subsites, and determine who’ll have access to using the different sections and on what content. As an example, we’ll set up our portal the following way.
1 Home
2 -Welcome (For all users)
3 -Employees (For users of type Employee)
–Orientation
–TeamBlogs
–KnowledgeBase
4 -Clients (For users of type Client)
–Projects
–Announcements
–Stakeholders
5 -About (For all users)

This is our portal structure, notice that under the Employees and Client subsites, I’m creating specific subsites that will cater to the type of user that’s logged in to my portal (If you want to read more on how to manage site groups and permissions, read this article: “Managing Site Groups and Permissions” http://office.microsoft.com/en-us/winsharepointadmin/HA011608101033.aspx).
Step 2: Manifest it.
Create the following file:
Your project SharePoint (AKA 12 Hive)\Template\SiteTemplates\RMSIManifest\RMSIPortalHomeManifest.xml
In this case, for the bottom-level subsites (like Employees/Orientation, or Clients/Projects), I’m using OOTB (Out Of The Box) site templates (like “STS#0″, which is the SharePoint Team collaboration site template).
By the way, you MUST have the following URL bookmarked; “List of Out of Box (OOB) Site Templates” http://blumenthalit.net/blog/Lists/Posts/Post.aspx?List=35b60df2%2D0af2%2D4e52%2D8c6f%2Dd3a64a542f45&ID=45
In all other cases, I’m using a custom site definition marked with my portal’s home site definition prefix (RMSIHome) followed by a numeric identifier. Note that this is not necessary, you’re better off using the OOTB site templates since they usually have what you would normally need. But if you would rather create a custom site definition rather than use a basic Publishing site, then follow this article through including Step 4.
If you want to read more on this discussion (the cons of creating custom site definitions), read: “Andrew Connell’s post on Site Definitions” http://www.andrewconnell.com/blog/archive/2008/02/15/You-dont-need-to-create-site-definitions.aspx
Step 3: Define it.
Create the following “WEBTEMP” file: *12 Hive*\Template\1033\XML\webtemp.RMSIPortal.xml
Notice that we’re leveraging the “PortalProvisioningProvider” (which implements SPWebProvisioningProvider), this takes the data found in “RMSIPortalHomeManifest.xml” from Step 1, and generates a portal structure based on that information. If you want exact details on the properties I used in the above example, read this article: http://blogs.technet.com/apurdon/default.aspx
Important! I’ve run into the problem where I was in an infinite loop and produced a vague “Stack Overflow” error. Took me a while to figure out that the reason was because I was using the same name in my Portal template (above) as in the site template “RMSIHome” (below) so save yourself some trouble, and ensure that they’re different as we’re doing here (in this case, I’ve named my template “RMSIPortal”).
Step 4 (optional): Refine it!
This step is only needed if you’re creating custom site definitions, so if all you’re using are OOTB templates like STS#0, you can skip this step.
Under SiteTemplates, create a folder called RMSIHome (this HAS to match your siteDefinition name prefix designated in your manifest file). In this folder, you will set up an ONET.xml file (which stands for an Office .NET file). You can reuse one of the OOTB Site Templates for this from this location: c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates.
Now, your file will contain all your site definitions indicated in Step 2, with the features used in each one of them, i.e.:
....
...
...
...
...
...
Notes:
What is Three-State Workflow?
This feature is used to track the status of a list item in three phases. As per the article below, “it can be used to manage business processes that require organizations to track a high volume of issues or items, such as customer support issues, sales leads, or project tasks.”
More info: “Use a Three-state workflow” http://office.microsoft.com/en-us/help/HA101544311033.aspx
What is a TeamCollab Feature?
This tells your site how to activate certain features that define the collaboration lists and libraries in a given “Team Collaboration” Site.
What is the MobilityRedirect Feature?
This feature allows you to support pocket PC and other PDA browsers by taking them to a customized “/m/default.aspx” page in your site. If you think mobility would be useful for your site, read this: “Custom Mobility Pages for SharePoint” http://www.iwkid.com/blog/Lists/Posts/Post.aspx?ID=36
For a list of all Farm, Site and Web Features in MOSS 2007 and their GUID’s, check this link:
“List of Features with GUIDs” http://www.thorprojects.com/blog/archive/2007/05/16/list-of-features-with-guids.aspx
Note: This helpful SharePoint portal blog post was originally posted at RapidMind Solutions.Com, Custom SharePoint Consultants.