In this example we're going to activate features, add a custom module, and add a few components to the modules. Well, let's jump right in.
1) Navigate to "12/Templates/1033/xml" and make a copy of the "webtempsps.xml" file. Paste this file directly back into the directory and rename it to "webtempLite.xml".
2) Open the newly copied "webtempLite.xml" and remove everything except for the following:
< ?xml version="1.0" encoding="utf-8"? >
< !-- _lcid="1033" _version="12.0.4518" _dal="1" -- >
< !-- _LocalBinding -- >
< ows="Microsoft SharePoint">
< name="lightDefn" id="10019">
< Configuration
ID="0"
Title="Light Site Definition"
Hidden="FALSE"
ImageUrl="/_layouts/images/stsprev.png"
Description="A Light pass through of a site definition"
DisplayCategory="LightDefinitions" >
< /Configuration >
< /Template >
< /Templates >
Let's just discuss the items in here lightly. You'll notice a few elements that should jump right out of the page. The first being the "Template" element, this element contains all of the references pertaining to a particular Site Definition. There a couple of special attributes that come with this:
Name (The name of the SiteDefinition folder living in "12/Templates/SiteTemplates")
ID (The the unique identifier for the named SiteDefinition)
Within this element you'll notice the "Configuration" Element. A Site Definition can contain several configurations, each using the portal resources in a different way to offering an alternative configuration. In the case of our Site Definition you'll recognize that we are only using configuration "0" which is the default configuration for most Site Definitions. The "Configuration" has a few attributes that are necessary:
ID (The unique identifier for the configuration, default is normally 0)
Title (The display name shown in the "Create Site" template list)
Hidden (true if hidden, false if not)
ImageUrl (This is the image displayed in the "Create Site" page when this list is selected)
Description (The description of this site definition)
DisplayCategory (The category of the Site Template under [i.e Collaboration, Publishing, etc..])
These are a few of the attributes, there are plenty of others, I show a few additional attributes in my previous post on Provisioning Scripts
3) Now that we have a "webtemp" file, let's go and create a SiteDefinition folder that's referenced in the "webtemp" file. Navigate to "12/Templates/SiteTemplates" and make a copy the "SPS" folder and paste it directly in this folder, rename this folder to "lightDefn".
4) Now that we have most all of the referenced files, let's get to the meat of this stuff. Navigate to "12/Templates/SiteTemplates/lightDefn/xml". In here you'll notice a file named "onet.xml" this file is the "orchestrator" for what and how this Site Definition will be created. Open this file up in visual studio or your favourite xml editor and follow my lead (We will tackle this in sections as needed):)
5) The majority of the elements in a site definition will not have to be modified when you create these from existing site definitions. The "onet.xml" file is broken up into a few parts and is very easy to follow if you understand the schema, it consists of a few wrapping elements:
We'll only be touching the ones necessary to complete this example. For starters, let's turn on a few features. Modify the "webfeatures" element to look as such:
<>
< !-- Publishing feature -- >
< id="22A9EF51-737B-4ff2-9346-694633FE4416">
< xmlns="http://schemas.microsoft.com/sharepoint/">
< key="WelcomePageUrl" value="$Resources:cmscore,List_Pages_UrlName;/Default.aspx">
< key="SimplePublishing" value="true">
< /Properties >
< /Feature >
< id="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
< !-- Per-Web Portal Navigation Properties-- >
< xmlns="http://schemas.microsoft.com/sharepoint/">
< key="InheritGlobalNavigation" value="true">
< key="IncludeSubSites" value="true">
< /Properties >
< /Feature >
< id="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5">
< !--Announcements-- >
< id="00BFEA71-D1CE-42de-9C63-A44004CE0104">
< /WebFeatures >
This is pretty straight forward. There are few different types of features, FarmFeatures, SiteFeatures, and WebFeatures., each of these elements are referring to feature activation scopes and the realm the apply to. In our case because we're only activating lists, these are only "webfeatures". The only attribute that's unique to the feature elements is the "Id" which references the unique identifier of the feature being activated.
6) Now that we have our list features activated, let's tell SharePoint that they exist. Modify the "Lists" element section to look as such:
< title="Announcements" description="This is an Announcements List" type="104" url="Lists/Announcements" featureid="00BFEA71-D1CE-42de-9C63-A44004CE0104">
Notice in this section the only real work we're doing is specifying the value for the following attributes:
type
url
name
description
featureId
All of this information can be found in the "12/Templates/Features/[list]" for the particular list you'd like to activate. The feature folders are open to "public" view and can referenced anytime you're wondering about attribute values for features you'd like to activate.
7) Now that we have a lot of our references needed , let's create a module to act as the landing page of a site based on our Definition. Edit the first "modules" section to look as such:
<>
< name="Lite">
< /Modules >
OK now this is just referencing the modules to be used in the specific configuration, modify the second "modules" section outside the configuration element as such:
<>
< name="Lite" url="$Resources:cmscore,List_Pages_UrlName;" path="">
< url="Default.aspx" type="GhostableInLibrary">
< name="Title" value="Lite">
< name="ContentType" value="$Resources:cmscore,contenttype_welcomepage_name;">
< name="PublishingPageLayout" value="~SiteCollection/_catalogs/masterpage/defaultlayout.aspx, $Resources:spscore,DefaultLayoutTitle;">
< /File >
< /Module >
< /Modules >
Alright, now we have a few things to cover in this section. This section defines the modules available for the site definition. Each configuration can reference as many of these as are available. Let's discuss the element/attributes of the "module" definition. The first element is the "module" element which has a few attributes:
Name (the name of the module)
Url (the url path to the module)
Path (The path to the module)
Within this element we also have the "file" element, this element represents the file we will be provisioning. This element also has a few attributes described below:
Url (the url path to the file)
Type ("ghostableinlibrary" for files that will live in pages gallery, masterpage gallery, and styles library)
Level (next post)
I've really only touched the surface on these attributes, I'll discuss them in more detail on my next site definition post. Within the "file" element we have a few "property" elements. These elements set properties of the file being provisioned. Each of the properties have attributes that mimic a name/value pair. One of properties that we'll discuss in this pass is the "PublishingPageLayout" property. This property is the relative path to a page layout living in the masterpage gallery. It generally is formed like this:
"~SiteCollection/_catalogs/masterpage/[pagelayout].aspx"
This is pretty straight forward. A common practice is to create a feature that provisions a pagelayout to the MasterPage gallery, activate this feature in a configuration in the site definition, and reference that pagelayout in this "PublishingPageLayout" property.
Now that we have the test bed, let's add some components to the file we're provisioning. Modify "file" element to look like this:
< url="Default.aspx" type="GhostableInLibrary">
< name="Title" value="Lite">
< name="ContentType" value="$Resources:cmscore,contenttype_welcomepage_name;">
< name="PublishingPageLayout" value="~SiteCollection/_catalogs/masterpage/defaultlayout.aspx, $Resources:spscore,DefaultLayoutTitle;">
< webpartzoneid="TopZone" webpartorder="1">< ![CDATA[
<>
< xmlns="http://schemas.microsoft.com/WebPart/v3">
<>
< name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
<>$Resources:spscore,WPImportErrorMessage;< /importErrorMessage >
< /metaData >
<>
<>
< name="Title" type="string">$Resources:spscore,RecentNewsWP_Title;< /property >
< name="ChromeType" type="chrometype">
< name="XslLink" type="string">/Style Library/XSL Style Sheets/ContentQueryMain.xsl< /property >
< name="CommonViewFields" type="string">
< name="SortBy" type="string">
< name="SortByDirection" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+SortDirection,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="ItemStyle" type="string">
< name="ItemLimit" type="int">
< name="CacheDataTimeout" type="int">
< name="ListName" type="string">$Resources:cmscore,PagesListDisplayName;< /property >
< name="WebUrl" type="string">~Site< /property >
< name="FilterField1" type="string">{c042a256-787d-4a6f-8a8a-cf6ab767f12d}< /property >
< name="FilterOperator1" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterValue1" type="string">$Resources:cmscore,contenttype_redirectpage_name;< /property >
< name="FilterType1" type="string">
< name="Filter1ChainingOperator" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterChainingOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterField2" type="string">{c042a256-787d-4a6f-8a8a-cf6ab767f12d}< /property >
< name="FilterOperator2" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterValue2" type="string">$Resources:cmscore,contenttype_articlepage_name;< /property >
< name="FilterType2" type="string">
< /properties >
< /data >
< /webPart >
< /webParts >]] >
< /AllUsersWebPart >
< list="Lists/Announcements" baseviewid="1" webpartzoneid="TopZone" webpartorder="2">
< /File >
Let me explain the way each of the element entries work. You'll notice a few elements named "AllUsersWebParts" , this element is a place holder for a web part on the file we're provisioning. This element has a few attributes:
WebPartZoneID (The reference to a WebPart zone in the correlating page layout, this zone is where the webpart will be placed)
WebPartOrder (Order of the webpart in the zone, this is 1 based)
Now, inside this element there is a bit of CDATA that seems like an xml blob. If you're SharePoint savvy, you'll notice that the data in here is the contents of a WebPart manifest.
**Note: A simple way to get the contents of this section is to export the WebPart you'd like to have on a page from an existing page (make sure the WebPart's editor part has the "allow export" check-box checked). On export you'll receive the web part manifest with the configurations of the web part in it's current state. **
I'll be sure to get into this in more detail on my second pass. Another attribute you'll notice is the "view" element. This element references a view in the lists we made available in this site definition. The "view" element has a few attributes that should be recognized:
List (The reference to the list this view belongs to, this can either be the url (Lists/[listname]) or the list type (100, 101))
BaseViewID (The reference to the View to display from the particular list **note ViewID to is not a valid ID for out of the box lists**)
WebPartZoneID (The reference to the zone this list will be placed)
WebPartOrder (The order in which the WebPart will sit in the zone)
That pretty much explains all of the items we're touching in this example :) Let's look at the whole "Onet.xml" file and you can compare.
< ?xml version="1.0" encoding="utf-8" ? >
< revision="10" title="$Resources:spscore,PortalTitle;">
<>
< name="SharePoint Top Navbar" id="1002">
< /NavBar >
< /NavBars >
<>
< /ListTemplates >
<>
<>
< id="-1" name="NewWeb">
< id="0" name="Default">
<>
< title="Announcements" description="This is an Announcements List" type="104" url="Lists/Announcements" featureid="00BFEA71-D1CE-42de-9C63-A44004CE0104">
< /Lists >
<>
<>
< !-- Publishing feature -- >
< id="22A9EF51-737B-4ff2-9346-694633FE4416">
< xmlns="http://schemas.microsoft.com/sharepoint/">
< key="WelcomePageUrl" value="$Resources:cmscore,List_Pages_UrlName;/Default.aspx">
< key="SimplePublishing" value="true">
< /Properties >
< /Feature >
< id="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
< !-- Per-Web Portal Navigation Properties-- >
< xmlns="http://schemas.microsoft.com/sharepoint/">
< key="InheritGlobalNavigation" value="true">
< key="IncludeSubSites" value="true">
< /Properties >
< /Feature >
< id="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5">
< !--Announcements-- >
< id="00BFEA71-D1CE-42de-9C63-A44004CE0104">
< /WebFeatures >
<>
< name="Lite">
< /Modules >
< /Configuration >
< id="1" name="Blank">
< /Configurations >
<>
< name="Lite" url="$Resources:cmscore,List_Pages_UrlName;" path="">
< url="Default.aspx" type="GhostableInLibrary">
< name="Title" value="Lite">
< name="ContentType" value="$Resources:cmscore,contenttype_welcomepage_name;">
< name="PublishingPageLayout" value="~SiteCollection/_catalogs/masterpage/defaultlayout.aspx, $Resources:spscore,DefaultLayoutTitle;">
< webpartzoneid="TopZone" webpartorder="1">< ![CDATA[
<>
< xmlns="http://schemas.microsoft.com/WebPart/v3">
<>
< name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
<>$Resources:spscore,WPImportErrorMessage;< /importErrorMessage >
< /metaData >
<>
<>
< name="Title" type="string">$Resources:spscore,RecentNewsWP_Title;< /property >
< name="ChromeType" type="chrometype">
< name="XslLink" type="string">/Style Library/XSL Style Sheets/ContentQueryMain.xsl< /property >
< name="CommonViewFields" type="string">
< name="SortBy" type="string">
< name="SortByDirection" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+SortDirection,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="ItemStyle" type="string">
< name="ItemLimit" type="int">
< name="CacheDataTimeout" type="int">
< name="ListName" type="string">$Resources:cmscore,PagesListDisplayName;< /property >
< name="WebUrl" type="string">~Site< /property >
< name="FilterField1" type="string">{c042a256-787d-4a6f-8a8a-cf6ab767f12d}< /property >
< name="FilterOperator1" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterValue1" type="string">$Resources:cmscore,contenttype_redirectpage_name;< /property >
< name="FilterType1" type="string">
< name="Filter1ChainingOperator" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterChainingOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterField2" type="string">{c042a256-787d-4a6f-8a8a-cf6ab767f12d}< /property >
< name="FilterOperator2" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c">
< name="FilterValue2" type="string">$Resources:cmscore,contenttype_articlepage_name;< /property >
< name="FilterType2" type="string">
< /properties >
< /data >
< /webPart >
< /webParts >]] >
< /AllUsersWebPart >
< list="Lists/Announcements" baseviewid="1" webpartzoneid="TopZone" webpartorder="2">
< /File >
< /Module >
< /Modules >
< /Project >
8) Now it's time to test this bad boy, save all of your files and reset iis. If you go into your portal you and create a site, you should notice an entry for our new Site Template is available. Give it a try! I know this is a lot, but this is just a lite version. In order for me to cover this in full it'll take a few passes.
Hope this helps,
~:)
5 comments:
It looks like your blog software ate the element names in your code samples!
Too bad when bloggers do not proofread their own posts. It's unreadable :-(
When i used "property name="WebUrl" type="string"> ~Site " in onet.xml and create the new site.. when i click modifiy sharewebpart i got this error.."It may have been deleted by another user."
So I tried "property name="WebUrl" type="string">~Site/Categories Then when i click modifiy sharewebpart i got "There is a problem with the query that this Web Part is issuing. Check the configuration of this Web Part and try again." Because i saw "/subsitename/Categories/Categories" ...Categoies should be only one time.. if it is "/subsitename/Categories", i will work..(Categories is my custom list).
So i had to deleted manually one Categories..
SO Could you help me how to solve it? Thanks a lot.
I am looking forward your reply.
Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!
ups sorry delete plz [url=http://duhum.com].[/url]
Post a Comment