Tuesday, March 6, 2012

Visual Studio 2011 Beta - Creating Site Definition

This is just to quickly share some views on how to create a custom site definition using Visual Studio 2011 Beta.

This is a great enhancement for someone like me who really remembered all XML tags which are in Onet.xml / Site Definition. Now you dont have to do this manually at all , just create a solution and add new site definition in it using UI. How ? here is the answer.

I have created a sample solution using VS 2011 beta and adding new SharePoint site definition to it.

I have just added a new site definition to the project and given name as TestSiteDefinition.

Once you are done with these clicks , take a look at the solution explorer and see which are the files which are added. VS adds all files related to site definition like Onet.xml , webtemp_*.xml and a default page automatically , which we used to write and add manually for MOSS 2007 and SharePoint 2010 using previous versions of VS.

Lets take a look at each file -

1. default.aspx - This is a standard SharePoint page with default.master as master page and has only   twocontent controls on it which refers to the PlaceHolders from maste page - one is PlaceHolderPageTitle and other is PlaceHolderMain. You can now edit the file and add your customizations on it.

2. Onet.xml - This file contains all elements like Project, NavBars,Configuration and Modules. By default no feature is added in the SiteFeatures and WebFeatures elements of default configuration ID 0 , and a module is added whcih points to the default.aspx page. but wondering why ListTemplates and DocumentTemplate elements are missing here.
You can read more on onet.xml here

3. webtemp_TestSiteDefinition.xml - This file contains Template element. custom template is given ID of 10000 by default and display category is SharePoint Customizations by default.

Now I will just right click the solution and deploy this custom site definition and see what happens - and here is the output

Conclusion : Now with the new version of VS it is much easy to create site definitions and get started with your customizations.

No comments:

Post a Comment