Friday, October 23, 2009

Creating Site Definitions? The Best way, is actually not creating one.

Not exactly, NOT creating a new one, but create a lightweight one.

The Point is to create minimal site definition(nothing more than the ID and name) and put all custom lists, webparts etc in features and just staple with the site definition so that they get activated when the site is created.
Described here:
http://www.andrewconnell.com/blog/archive/2008/02/15/You-dont-need-to-create-site-definitions.aspx


Raymond Mitchell takes it to the next level by describing a way where you will truly be independent from the custom site definition to the point of being able to delete the custom site definition, He also describes the different ways to create a new site, without creating a site definition at all.
His best approach solves two problems:
1. Making further changes to site definition, lists and webparts in it.
2. Deleting the site definition and keeping it updated with new version.

http://www.iwkid.com/blog/Lists/Posts/Post.aspx?ID=53

When you install the site definition/template, and when users are creating a new site based on that, the site provisioning handler will create the site based on the custom site definition. But if you hijack it and use applywebtemplate method you can make the site created based on OOTB site definition. This way you are free to delete your custom site definition and the sites will still work. The trick is to hijak the site provision handler and use the method applywebtemplate method and apply the OOTB site definition instead of the custom site definition. Excellent Idea by: Raymond Mitchell.

The word doc of the post in SharePoint folder.

No comments:

Post a Comment