Wednesday, July 18, 2007

Customizing the out of the box Collaboration Portal

Creating an entire Collaboration Portal definition, based on the out of the box definition, inside of SharePoint 2007 can be a very stressful thing to do. Once you get your head wrapped around what is really going on its quite simple.

By following the steps below, you will be able to replicate the out of the box portal defintion and then you will be able to customize from there.

Copy and rename the following directories listed below:

  • C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\SPS – rename "MYCOMPANYCOLLECTIONSITEDEFINITION"
  • C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\SPSNHOME – rename "myCompanyNews"
  • C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\SPSSITES – rename "myCompanySites"
  • C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\BDR – rename "myCompanyDocCenter"
  • C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\SRCHCEN – rename "myCompanySearchCenter"

Create a new WebTemp*.xml file

The new webTemp*.xml file should be located under here C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML and name it WebTempMyCompany.xml

You can insert the following code:

<?xml version="1.0" encoding="utf-8"?>
<Templates xmlns:ows="Microsoft SharePoint">
<!--
MYCOMPANY Collections Site Template -->
<
Template Name="MYCOMPANYCOLLECTIONSITEDEF" ID="10500">
<
Configuration ID="0" Title="MYCOMPANY Collection Site" Hidden="FALSE"
ImageUrl="/_layouts/1033/images/template_corp_intranet.png"
Description="This is a collection site for MyCompany"
ProvisionAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ProvisionClass="Microsoft.SharePoint.Publishing.PortalProvisioningProvider"
ProvisionData="xml\\MYCOMPANYCollectionWebManifest.xml"
RootWebOnly="TRUE"
DisplayCategory="MYCOMPANY"
Type="0"
VisibilityFeatureDependency="DF4041D0-9959-43fb-A408-8797632B51E7">
</
Configuration>
</
Template>
<!--
MYCOMPANY Collection Site Definition -->
<
Template Name="MYCOMPANYCOLLECTIONSITEDEFINITION" ID="10501" >
<
Configuration ID="0" Title="MYCOMPANY SharePoint Portal Server Site" Type="0" Description="This template is obsolete, but must be here!" Hidden="TRUE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="MYCOMPANY" />
</
Template>
<!--
MYCOMPANY News Site -->
<
Template Name="MYCOMPANYNews" ID="10502" >
<
Configuration ID="0" Title="MYCOMPANY SharePoint Portal Server News Site" Type="0" Description="This template is obsolete, but must be here!" Hidden="TRUE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="MYCOMPANY" />
</
Template>
<!--
MYCOMPANY Document Center Site -->
<
Template Name="MYCOMPANYDocumentCenter" ID="10503" >
<
Configuration ID="0" Title="MYCOMPANY SharePoint Portal Server Document Center Site" Type="0" Description="This template is obsolete, but must be here!" Hidden="TRUE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="MYCOMPANY" />
</
Template>
<!--
MYCOMPANY Site Directory -->
<
Template Name="MYCOMPANYSiteDirectory" ID="10504" >
<
Configuration ID="0" Title="MYCOMPANY SharePoint Portal Server Site Directory" Type="0" Description="This template is obsolete, but must be here!" Hidden="TRUE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="MYCOMPANY" />
</
Template>
<!--
MYCOMPANY Search Center -->
<
Template Name="MYCOMPANYSearchCenter" ID="10505" >
<
Configuration ID="0" Title="MYCOMPANY SharePoint Portal Server Search Center" Type="0" Description="This template is obsolete, but must be here!" Hidden="TRUE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="MYCOMPANY" />
</
Template>
</
Templates>

As you will notice there are two different configuration element structures. The first one is the configuration that is going to build your Collaboration Portal.

  <Template Name="MYCOMPANYCOLLECTIONSITEDEF" ID="10500">
<
Configuration ID="0" Title="MYCOMPANY Collection Site" Hidden="FALSE"
ImageUrl="/_layouts/1033/images/template_corp_intranet.png"
Description="This is a collection site for MyCompany"
ProvisionAssembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
ProvisionClass="Microsoft.SharePoint.Publishing.PortalProvisioningProvider"
ProvisionData="xml\\MYCOMPANYCollectionWebManifest.xml"
RootWebOnly="TRUE"
DisplayCategory="MYCOMPANY"
Type="0"
VisibilityFeatureDependency="97A2485F-EF4B-401f-9167-FA4FE177C6F6">
</
Configuration>
</
Template>

Since the Collaboration Portal is using publishing, we must call the publishing assembly and provide provisioning data. The provisioning data file is where we will tell the portalProvisioningProvider what webs to create for our portal. More on that file later. The other three key items to take note of are the DisplayCategory, RootWebOnly and VisibilityFeatureDependency attributes.


  • DisplayCategory attribute is the name of the tab you want your definition to be located under on the _layouts/scsignup.aspx page.
  • RootWebOnly attribute is pretty much self explanatory, but set to TRUE and your definition will only be shown on the _layouts/scsignup.aspx page if a root site can be created.
  • VisibilityFeatureDependency attribute, only if the feature referenced there is turned on can the site be created. If the feature is not turned on your definition will not show up on the _layouts/scsignup.aspx page.

You will notice that there are several template elements where the Hidden attribute is set to TRUE, I have done this because every site definition you create needs a unique ID (above 10000) and I am only letting my users use those site definitions when they create a Collaboration Portal. If you set Hidden to False, your users will be able to create sites based on that single site definition alone.

ProvisioningData file:

This is the file that you will create your portal structure from. This file contains all the webs to be created. Create a new xml document under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML and name it MYCOMPANYCollectionWebManifest.xml and insert the following code:

<?xml version="1.0" encoding="utf-8"?>
<portal xmlns="PortalTemplate.xsd">
<
web name="Home" siteDefinition="MYCOMPANYCOLLECTIONSITEDEFINITION#0" displayName="Home" description="MYCOMPANY Portal Home Site">
<
webs>
<
web name="News" siteDefinition="MYCOMPANYNews#0" displayName="$Resources:spscore,PortalManifest_News_DisplayName;" description="$Resources:spscore,PortalManifest_News_Description;" />
<
web name="SiteDirectory" siteDefinition="MYCOMPANYSiteDirectory#0" displayName="$Resources:spscore,PortalManifest_SiteDirectory_DisplayName;" description="$Resources:spscore,PortalManifest_SiteDirectory_Description;" />
<
web name="SearchCenter" siteDefinition="MYCOMPANYSearchCenter#0" displayName="$Resources:spscore,PortalManifest_SearchCenter_DisplayName;" description="$Resources:spscore,PortalManifest_SearchCenter_Description;" />
<
web name="Docs" siteDefinition="MYCOMPANYDocumentCenter#0" displayName="$Resources:spscore,PortalManifest_DocumentCenter_DisplayName;" description="$Resources:spscore,PortalManifest_DocumentCenter_Description;" />
</
webs>
</
web>
</
portal>

You will notice above in the structure you have a web element followed by a webs element followed by more web elements. You got it; it is telling the PortalProvisioningProvider to create a web with several sub webs. The SiteDefintion attribute contains the name of the site definition you want to use to create the web and the "#0" is the configuration you want to use in the onet.xml of that site definition. As a good practice, always use the "#n" even if you only have one configuration in the onet file.


The second configuration element structure does not contain the PortalProvisoningProvider therefore it will only create that single site.


Now you might be thinking, we’re done, let’s create a site... Nope, it will go boom, if you do so. So we still have several files to create and or modify. First we are going to look back at the WebTempMYCOMPANY.xml file and at the VisibilityFeatureDependency attribute.  This is calling the BaseSiteStapling feaure, this feature will staple several features to site definitions listed in that feature. For example it will staple the BaseSite feature to the SPS#0 site definition.  To get this to work with your new site definition you have two choices: You can either add reference to your definitions in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\BaseSiteStapling\basesitestapling.xml or you can create a custom stapled feature, so you do not have to modify out of the box code, just incase a service pack overwrites your modifications.

To create your own custom BaseSiteStapling feature copy C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\BaseSiteStapling and rename it to MYCOMPANYBaseSiteStapling.  Modify the Feature.xml file by giving it a new GUID for it's ID.  You could also rename the xml file for the location attribute to mycompanybasesitestapling.xml, if you do this make sure you rename the actual file too.  Now edit the mycompanybasesitestapling.xml as follows:

<?xml version="1.0" encoding="utf-8" ?>
<
Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYDocumentCenter#0" />
<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYCOLLECTIONSITEDEFINITION#0" />
<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYCOLLECTIONSITEDEF#0" />
<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYNews#0" />
<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYSiteDirectory#0" />
<
FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MYCOMPANYSearchCenter#0" />

<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYDocumentCenter#0" />
<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYCOLLECTIONSITEDEFINITION#0" />
<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYNews#0" />
<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYSiteDirectory#0" />
<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYCOLLECTIONSITEDEF#0" />
<
FeatureSiteTemplateAssociation Id="99FE402E-89A0-45aa-9163-85342E865DC8" TemplateName="MYCOMPANYSearchCenter#0" />

</
Elements>

There are two other stapled features you have to modify in the same way. 



  • PublishingStapling
  • PremiumSiteStapling

Follow the same steps above and keep the following in mind:


  • SPS#0 = MYCOMPANYCOLLECTIONSITEDEFINITION#0
  • SPSNHOME#0 = myCompanyNews#0
  • SPSSITES#0 = myCompanySites#0
  • BDR#0 = myCompanyDocCenter#0
  • SRCHCEN#0 = myCompanySearchCenter#0
  • SPSPORTAL#0 = MYCOMPANYCOLLECIONSITEDEF#0

    At this point the Collaboration Site Definition you created will work, it's up to you to modify the onet.xml files for each site definition and create and/or modify the out of the box master pages, page layouts, content types, site columns...

  • 13 comments:

    Fedro Ponce de Leon said...

    I have reproduced the procedure you depicted but the MYCOMPANY tab is never shown... I tested by removing the VisibilityFeatureDependency attribute from webtempMYCOMPANY.xml thus the tab and subsites are shown.
    I have a doubt:
    ¿Does the GUID in this file should be set to the GIUD in MYCOMPANYBaseSiteStapling\feature.xml file?
    I tested that but the tab is still not being shown. ¿Could that be related to "activating" these features with the Central Administration?

    Tony said...

    Fedro - Yes, point VisibilityFeatureDependency to the GUID of the MyCompanyBaseSiteStapling. If you are going to install each feature in the definition separately then you should activate the features too. The best way to deploy the definition would be to create a solution. Get a copy of WSPBuilder to build the solution; it’s a big time saver.

    Phil said...

    I did all you mentioned but if I'll create the Site Collection an error occured: Failed to instantiate file "default.master" from module "DefaultMasterPage": Source path "default.master" not found.

    I deployed the Custom Collaboration Portal by a wsp-file. But this should work, or not?

    dattard said...

    Nice post, cheers.

    Anonymous said...

    Tony, good work on the article and details.

    I am trying to do a similar effort by customizing a Collaboration Portal Template, except to exclude the News and Docs pages. The Site Directory and Search need to be included and they are out of the box, but they need the custom master page applied to it.

    In addition, the default.aspx should remain the same name and have custom web parts with content. For instance, have a links web part and two custom content editor web parts on the default.aspx I undersand these web parts need to be referenced under the AllUsersWebPart tag in the custom Onet.xml.

    Can you show us how to exclude the two pages (News and Docs)from the portalwebmanifest.xml or other location? and how to customize the default.aspx with a links web part and editor content web part? Thanks.

    Anonymous said...

    Tony,
    Thanks for the post. Can you show how to add a custom master page to the custom site definition? Also, how to reference a custom theme already deployed? That is, after provisioning, the custom site definition contains both the custom master page and is set to the custom theme. Thanks.

    Saurabh said...

    Hi ..... is there any role of ONET.XML ??

    Saurabh said...

    Hi Tony.....NICE article

    Can u please tell us what Type of Changes we have to do in Onet.XML .
    It will help alot.....

    Thanx n Regards
    Saurabh

    Anonymous said...

    Brilliante..... I looked around for how to create a custom Collaboration Site Def but all people had was creating custom STS Definition.

    Thanks.

    Anonymous said...

    In regards to the three stapling files, are we to remove all the other FeatureSiteTemplateAssociation's and only include the ones shown in your article?

    Anonymous said...

    Hi,
    Great article, however I am having a similar issue to Fedro. When I point my webtemp*.xml at the new feature, it disappears. However it shows up when I'm pointing at the OotB BaseSiteStapling feature. Any suggestions?

    Thanks,
    Michael

    Anonymous said...

    Hi..i have followed your blog but i am having problems when i create the site..my createsite.aspx file just freezes then goes to a 404 page. It seems to time out..Do you have any idea what may cause this?

    Thanks

    Chris

    modiyam said...

    Hi Tony,

    Excellent artical, but i have one dought, when ever we create a site using Collaboration template, it will automatically create Document Center, News, Search , Site and Reports. i'm able to find out from your artical how the Document center, News, Search and Site, but not able to figure out how the Reports subsite is creating could you please show me how this Reports subsite is creating,

    Thanks
    Modiyam