Loading...

Sunday, October 10, 2010

Fundamentals of Site Definition

Here I will add  details on following Placeholders (with respect to SP2007/2010)
Site definition is defining the site with prefigured set of Sharepoint Objects

1)How to provision Pages with Master Page ,Page Layouts ,Images and CSS,
1)Define the feature for Page which combines Pagelayouts   and Webparts  and other contents  of the page  as follows


Elements.xml
(Define all the pages with GhostableInLibrary  attribute, which makes pages available in site)


<module Name="WelcomePage" Url="Pages" Path="Pages">
<file Url="Welcome.aspx" Path="page.aspx" NavBarHome="True" Type="GhostableInLibrary">
<property Name="Title" Value="Welcome" />
<!--<property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/VillageLayout.aspx,Custom Layout" />-->
<property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomLayout.aspx, Custom Layout" />



Feature.xml
Define the Web Scoped Feature
  define the feature  for the Pages in following  path of solution
solution Name\Site Definations\12\TEMPLATE\FEATURES\WebPages\Pages

Stapple this feature  with   Feature Stappler
Feature Stappler is the Farm level feature which associates Site  Template  with Feature Id  in its elements.xml
as follows

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Master Page Files -->
<FeatureSiteTemplateAssociation Id="6A4E5195-B0C0-42cb-B4AC-C18E72276A78"
TemplateName="TemplateName#0"/>

<!-- Site -->
<FeatureSiteTemplateAssociation Id="07A8588D-CFB5-46bd-A315-6FA80E31AAA6"
TemplateName="TemplateName#0"/>

<!-- Web -->
<FeatureSiteTemplateAssociation Id="72E6C98A-3E37-4a4a-81F5-504A48A646CC"
TemplateName="TemplateName#0"/>

<!-- Feature Executing at site level -->
<FeatureSiteTemplateAssociation Id="2772D112-519A-43A2-AB91-8FE93B6130BE"
TemplateName="TemplateName#0"/>
</Elements>


Where TemplateName   is  Folder at location
solution name\Site Definations\12\TEMPLATE\XML\SiteTemplates\TemplateName 
Which contains the Onet.xml

2)How to Provision Webparts
In   above elements.xml specify the webparts which are prefigured on  page when site is loaded

<module Name="WelcomePage" Url="Pages" Path="Pages" >
<file Url="Welcome.aspx" Path="page.aspx" NavBarHome="True" Type="GhostableInLibrary">
<property Name="Title" Value="Welcome" />
<!--<property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/VillageLayout.aspx,Custom Layout" />-->
<property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomLayout.aspx, Custom Layout" />
<alluserswebpart WebPartZoneID="g_1D8BB5ABF0A14891B0AC79621A17C840" WebPartOrder="1">
<![CDATA[
<webpart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">
<assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<typename>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
<frametype>None</FrameType>
<title>Site Image</Title>
<iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>
</WebPart>
]]>
</AllUsersWebPart>
<alluserswebpart WebPartZoneID="g_D6F8BAF418504B53B37617BC2FFD4A0C" WebPartOrder="1">
- <![CDATA[
<webpart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">
<assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<typename>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
<frametype>None</FrameType>
<title>Site Image</Title>
<iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>
</WebPart>


]]>
</AllUsersWebPart>



Tag AllUsersWebPart specifies the Image Webpart to  be loaded on the Page provisioned in above elements
Two important things here
WebPartZoneID="g_1D8BB5ABF0A14891B0AC79621A17C840"  ,this value is to be retrieved from  corresponding Page Layouts, In above case its  to  be retrieved from /CustomLayout.aspx

Second , To get the CData of webpart
Site Actions -->Site settings--->Gallary-->Webpart Gallary-->Copy the xml of webpart and paste into CData  

Next time I will elaborate on following   and pending placeholder Ids'

1)Creating feature for layouts and and associating it with Site definitions
Create   Site Scoped  feature for Layouts at location
solution Name\Site Definations\12\TEMPLATE\FEATURES\PageLayOuts

In elements.xml specify the pagLayouts to be provisioned as follows
>File Url="XYZPageLayout.aspx" Type="GhostableInLibrary"<


>Property Name="Title" Value="Custom Layout" /<

>Property Name="MasterPageDescription" Value="A custom  layout." /<

>Property Name="ContentType" Value="Page Layout" /<

>Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLeft.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLeft.png" /<

>!--

>/File<
 
where
XYZPageLayout.aspx  defines the webpartzones and webparts or other Page Contents

2)Associating above Page feature with Site definition 

< Feature xmlns="http://schemas.microsoft.com/sharepoint/"
 Id="Guid"
Scope="Web"
Hidden="FALSE"
Title="Executes when web is created"

Description="Executes when web is created"

Creator="swati"

ReceiverAssembly="fullnamedescription"

ReceiverClass="namespace.classname"

>

< ActivationDependencies >

< !-- Publishing -- >

< ActivationDependency FeatureId="22A9EF51-737B-4ff2-9346-694633FE4416"/ >

< !-- Navigation -- >

< ActivationDependency FeatureId="541F5F57-C847-4e16-B59A-B31E90E6F9EA" / >

< /ActivationDependencies >

< ElementManifests >

< ElementManifest Location="elements.xml"/ >

< /ElementManifests >

< /Feature >
where elements.xml    defines the structure  for Pages  as defined above
which includes xml for defining   layouts ,webparts etc.

3)How to Provision Lists with and Its contents

4)How to associate features with templates

5)How to Control Navigation properties of site from Onet.xml

Details about Implementing Site Definition in Sharepoint 2010

No comments: