5. Site Definitions
What are site definitions?
• Contains a server-side collection of files that
defines the structure of one or more site
templates.
Possible scopes
• Farm Level.
7. Site Definition Structure
- “Project” Element
It specifies a default name for sites that are created through any of the site configurations in the
site definition and specifies the directory that contains subfolders in which the files for each list
definition reside. Also contains information about AlternateCSS and CustomJSUrl etc.
- “NavBars” Element
It specifies the navigation area of the Site. Not necessarily a top navigation toolbar, it could be
tree of links.
- “ListTemplates” Element
Specifies the List Definition Information in the Site Definition.
- “DocumentTemplates” Element
Specifies the Document Libraries Information in the Site Definition.
8. Site Definition Structure
- “Configurations” Element
Each Configuration element in the Configurations section specifies the lists and modules that are
created by default when the site definition configuration is instantiated.
The “ID” attribute identifies the configuration (uniquely relative to the other configurations in
the site definition) and corresponds to the ID attribute of a Configuration element in
“WebTemp.xml”
- “Modules” Element
The Modules collection specifies the modules to include by default in creating a site collection.
Example: Module for MasterPage, DefaultPage of Site,
9. Site Definition Structure
Navigation Bars Pattern
<NavBars>
<NavBar Name="SharePoint Top Navbar" ID="1002">
</NavBar>
</NavBars>
Example:
<NavBars>
<NavBar Name="SharePoint Top Navbar" ID="1002">
<NavBarLink Name="Documents and Lists"
Url="_layouts/[%=System.Threading.Thread.CurrentThread.CurrentCulture.LCID%]/viewlsts.aspx"></NavBarLink>
<NavBarLink Name="Create"
Url="_layouts/[%=System.Threading.Thread.CurrentThread.CurrentCulture.LCID%]/create.aspx"> </NavBarLink>
<NavBarLink Name="Site Settings"
Url="_layouts/[%=System.Threading.Thread.CurrentThread.CurrentCulture.LCID%]/settings.aspx"></NavBarLink>
<NavBarLink Name="microsoft" Url="http://example.microsoft.com/"></NavBarLink>
</NavBar>
</NavBars>
19. Creating Publishing Site
1- Go To
“C:ProgramFilesCommonFilesMicrosoftSharedWebserverextens
ions14TemplatesSiteTemplates”
2- Click the SiteTemplate “PUBLISHING”
3- Click on “XML” folder and open the “onet.xml”
file
4- Copy and paste in to newly created visual studio
site definition “onet.xml” file with some
modifications where required.
30. Publishing Site
- Open “webtemp_CustomSiteName.xml” file
- Paste the text given below
<?xml version="1.0" encoding="utf-8"?>
<Templates xmlns:ows="Microsoft SharePoint">
<Template Name=“CustomCorporateSite" ID="100010">
<Configuration ID="0" Title=“Custom Corporate Site " Hidden="FALSE"
ImageUrl="/_layouts/images/CPVW.gif" Description=“Custom Corporate Site
Template" DisplayCategory=“Custom Site" RootWebOnly="true"
SubWebOnly="false">
</Configuration>
</Template>
</Templates>
31. Publishing Site
- RootWebOnly="true" To make site available at the site
collection level
- SubWebOnly=“true" To make site available at the sub site
level
- If you want to make the site only available at the site collection
level then make RootWebOnly="true" and SubWebOnly=“false“.
- If you want to make site definition only at sub site then make
RootWebOnly=“false" and SubWebOnly=“true“.
32. Publishing Site
Formats of Defining / make available of Site and Page Layouts
- AvailableWebTemplates "*-CustomDeptSite#0;*-CustomBlogSite#0“
In case of empty (“”)it will show all the site templates.
- AvailablePageLayouts
- "~SiteCollection/_catalogs/masterpage/MyCustomPageLayout.aspx“
In case of empty (“”)it will show all the page layouts.
- DefaultPageLayout
"~SiteCollection/_catalogs/masterpage/MyCustomPageLayout.aspx"
33. Publishing Site
Feature Stapling
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Site Columns -->
<FeatureSiteTemplateAssociation Id=“a5689e25-2139-453f-9367-99e4d12e510f"
TemplateName=“CustomDeptSite#0"/>
<!-- Site Content Types -->
<FeatureSiteTemplateAssociation Id=“19f9d02d-1bbc-45ac-a836-c0c73c0f1987" TemplateName="
CustomDeptSite#0 "/>
<!-- Site List Definitions -->
<FeatureSiteTemplateAssociation Id=“2c9e8ca5-d893-42b8-a3b3-cae4b18bf133" TemplateName="
CustomDeptSite#0 "/>
<!-- Site Settings List -->
<FeatureSiteTemplateAssociation Id=“109dd9fc-6018-4a81-8f8f-9ffdd8c68ef4"
TemplateName=“CustomDeptSite#0"/>
</Elements>