SharePoint 2010 General Lab for Developers (Part 2/5)



Starter files and solutions files can be found here.

In this Lab, we will focus on Site Definitions.

Create a Visual Studio 2010 SharePoint project called CourseSiteDef.

Add an homepage by adding the (starter) file Defaut.aspx into your project, but since the file will have to be deployed to 14\TEMPLATES\SiteTemplates\ in a custom folder named CS, add a SharePoint mapped folder to 14\TEMPLATES\SiteTemplates\ , create a sub folder named CS, and add the starter Default.aspx file into this location as illustrated in the next picture :


Now we have to fill in the different <TODO> in default.aspx.

Locate the TODO1 : we must specify that our page is a web part page and that it will use the default master page.

<%@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,

Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>

Locate the TODO2 where we will add instructions to display the breadcrumb control and we will connect the control to a navigation provider.

<asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>

Locate the TODO3 where we will specify that we want to define a web part zone

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left" />

Add a second web part zone in TODO4

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right" Title="loc:Right" />

In TODO5, we will display the title of the site

<SharePoint:ProjectProperty Property="Description" runat="server"/>

Take a look at ONET.XML from your starter files. This file will have to be deployed to 14\TEMPLATE\SiteTemplates\CS\XML : in the mapped folder you previously did, add a XML subfolder and copy ONET.XML in this location. You will notice 8 TODO that you will have to fill in:

In TODO1 and TODO2 we will define navigation nodes we want to have on the site

TODO1 will display these menu items on the top link bar, TODO2 will display them on the Quick launch; replace TODO1 and TODO2 with the following instructions:

<NavBarLink Name="Home" Url="default.aspx" />

<NavBarLink Name="Course Description" Url="CourseDescription.aspx" />

<NavBarLink Name="Resources" Url="Resources.aspx" />

In TODO3 we will define 2 list instances: we want a Document Library (type=101) instance an Announcement list (Type=104) instance:

<List FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101" Type="101" Title="$Resources:litware,doclib_Title;" Url="$Resources:litware,doclib_Folder;" />

<List FeatureId="00BFEA71-D1CE-42de-9C63-A44004CE0104" Type="104" Title="$Resources:litware,announceList_Title;" Url="$Resources:litware,lists_Folder;/$Resources:litware,announce_Folder;">




<Field Name="Title">$Resources:litware,announce_item_title;</Field>

<Field Name="Body">$Resources:litware,announce_item_body;</Field>

<Field Name="Expires">&lt;ows:TodayISO/&gt;</Field>





You will notice that our CAML code references text stored In resource file; these files must be deployed to the 14\Resources folder: in your Visual Studio project create a mapped folder to this folder and add the litware.en-US.resx and litware.resx files in this folder. Have a peek in them to see the definition of the various resources referenced in the ONT.XML.

Locate TODO4 and add a pointer to a Module element we will add in a moment:

<Module name=”default” />

Locate the TODO5 : we want 2 web parts on the homepage : the first will be based on the ListViewWebpart and will display the announcements and the second will be the image web part and will display a picture.

In snippet1.txt you will find:

<View List="$Resources:litware,lists_Folder;/$Resources:litware,announce_Folder;" BaseViewID="0" WebPartZoneID="Left" />

In TODO6, we want to add the ImageWebPart class preconfigured; add the text from snippet2.txt:

<AllUsersWebPart WebPartZoneID="Right" WebPartOrder="0">


<WebPart xmlns=";


<Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>



<Title>Home Page</Title>




Add the file LitwarebannerTS.jpg from the starter file into a course folder mapped to the Images folder.

2 other pages will be based on the same default.aspx template: the hompepage that we did, but also another page: coursedescription.aspx that will display the Content Editor web part: let’s define another File instruction (use snippet3.txt):

<File Url="default.aspx" Name="coursedescription.aspx" Type="Ghostable">

<AllUsersWebPart WebPartZoneID="Left" WebPartOrder="0">


<WebPart xmlns=";


<Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>


<Title>Course Description</Title>



Add here the course description






The last page that will be created from the default.aspx template is the resources.aspx page that will display the web site Resources document library.

Add a new file instruction in TODO8

<File Url="default.aspx" Name="resources.aspx" Type="Ghostable">

<View List="$Resources:litware,doclib_Folder;" BaseViewID="6" WebPartZoneID="Left" />


Now we need to make sure that our new site definition will be visible in the list of site templates: we must create an xml file with a name starting with webtemp and this must be deployed into the TEMPLATE\1033\XMLfolder file; so the best way to achieve that is a mapped folder.

Create a file called webtempCS.xml and add the content from the snippet5.txt.

<Templates xmlns:ows="Microsoft SharePoint" >

<Template Name="CS" ID="10006">

<Configuration ID="0"

Title="Litware Course Site"



Description="Use this site template for creating a site for a specific course."



SubWebOnly="false" />



Deploy your Package and create a new site based on your new site definition.

Our new template should show up in the Litware category


The created site will look like this:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s