The Collaboration Portal template included as a part of SharePoint 2007 is a template that I use most often because of the features that it provides. It is a central location for master pages and CSS styles that are used throughout the sub-site of the main portal. One problem I have found with this is that when a team site is created under a collaboration portal the master page is not applied. When I go to "Site Settings -> Look and Feel -> Master Page" after a team site is created I see the following error messages: This is because the Publishing Feature is not activated on a team site by default. I can do one of two things to correct this issue. One choice the master page I wish to apply to the site and second is to go to "Site Settings -> Site Administration -> Site Features" and enable the Office SharePoint Server Publishing feature. Either of these choices may not be an option if your organization has governance policies that dictate what master pages are applied to a team site when it is created. This is also a problem for site owners that may not know how to delve through the SharePoint Site Settings to find how to change the master page for their site, also if you are creating many sub-sites this could be an administrative burden. Trying to find newly created team sites and then applying the proper master page throughout each site in the site collection. In my search for an answer to this problem I found that there are many people who have either created a new team site definition or a SharePoint feature to fix this problem. Although a new site definition is a possible solution I do not need any new list or libraries with the team site when it created so I decided to go with a SharePoint feature to enable the Office SharePoint Server Publishing Feature when a team site is created. There is a little known feature (at least to me until lately) called the "Publishing Stapling" feature. What this feature does is it enables the Publishing feature on a select set of SharePoint site templates. Here are a few of the templates that are included in this feature: SPSPORTAL#0 – Collaboration Portal, CMSPUBLISHING#0 – Publishing Site. If you want to see all the templates included in this feature go to the following directory: "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingStapling" and look in the publishingStapling.xml file. Naturally these are sites that would have publishing enabled but what about the sites that are created under these publishing portal templates? After researching this subject I found that many people have created custom solutions that enable either the publishing feature or the automatic application of a master page upon site creation but I was looking for a solution that would not require code to be deployed to the SharePoint Server. I looked for and answer on Microsoft's MSDN and TechNet sites but only found the following: Retrieved from: http://support.microsoft.com/kb/936908 What is feature stapling? A basic explanation of feature stapling is that it is used to attach one or more features to a SharePoint site definition without modifying an existing site definition or creating a new site definition. Fro a more detailed explanation I recommend reading Chris Jonson's blog on "Feature Stapling in WSS V3". After reading this TechNet article I decided to create a simple stapling feature based off the Publishing Stapling feature that would be applied the SharePoint Publishing feature whenever a team site is created in the SharePoint Farm. This way when site owners create a new team site publishing will be enabled and the site will inherit the master page from the site above it. If the site owner wants to change the look and feel of the site they can either choose the default.master page or turn off the Publishing feature but the site will maintain the same look and feel of the main portal site throughout the site collection by default. So now how did I do this? The easy way would have been to add the STS#0 – Team Site into the existing Publishing Stapling feature but this file could be changed whenever an update or patch is applied, also it usually not a good idea to modify files in the 12 hive that are installed during the SharePoint installation. So I created a copy of the existing Publishing Stapling feature and then made modifications to the copied files. Here is a step by step explanation of what I did. Here is the original: "feature.xml" file: <?xml version="1.0" encoding="utf-8" ?> <Feature Id="001F4BD7-746D-403b-AA09-A6CC43DE7942" Title="Publishing Features Stapling" Description="Staple Publishing features" Version="12.0.0.0" Scope="Site" Hidden="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="publishingstapling.xml"/> </ElementManifests> </Feature> Here is the file after my modifications: <?xml version="1.0" encoding="utf-8" ?> <Feature Id="001F4BD7-746D-403b-AA09-A6CC43DE7943" Title="My Publishing Features Stapling" Description="My Staple Publishing features" Version="12.0.0.0" Scope="Farm" Hidden="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/"> <ElementManifests> <ElementManifest Location="Mypublishingstapling.xml"/> </ElementManifests> </Feature> As you can see only minor modification were made and I changed the Feature Id so it would not conflict with the existing Publishing Stapling feature and install properly. Also note that this feature is scoped to the entire farm, this feature could be scoped to the web application or site collection level depending on the requirements for your SharePoint Farm. Here is the original "MyPublishingStapling.xml" file. <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSPORTAL#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPS#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSREPORTCENTER#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSTOC#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSTOPIC#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSNEWS#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSNHOME#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SPSSITES#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="SRCHCEN#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="CMSPUBLISHING#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#0" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#1" /> <FeatureSiteTemplateAssociation Id="F6924D36-2FA8-4f0b-B16D-06B7250180FA" TemplateName="BLANKINTERNET#2" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSPORTAL#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPS#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSREPORTCENTER#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSTOC#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSTOPIC#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSNEWS#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSNHOME#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SPSSITES#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="SRCHCEN#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="CMSPUBLISHING#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#0" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#1" /> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="BLANKINTERNET#2" /> </Elements> Here is the file after I removed the default entries and added the Team Site definition: <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB" TemplateName="STS#0" /> </Elements> As you can see you could add other site definitions to this file so when any site is created the publishing feature is enable but we decided to only enable publishing on Team Sites since they are the most widely used. Although through feature stapling you could enable custom workflows to be enabled whenever a Meeting Workspace is created using this example. Once the files have been modified all that is left to do is to install the feature using stsadm.exe. Here are the commands I used to install the feature: Stsadm.exe –o installfeature –filename MyPublishingStapling\Feature.xml Once this command is completed the feature is installed. On the environments where I have installed this feature I did not have to activate it after installing the feature. I ran the activate feature command just to be safe. Stsadm.exe –o – activatefeature –filename MyPublishingStapling\Feature.xml Once this command completes it will state that the feature has already been activated to the farm. If you are installing and activating this feature to a web application or site collection the stsamd.exe command will be different. Please review Microsoft's site foe the stsadm.exe index of commands here: http://technet.microsoft.com/en-us/library/cc263384.aspx The last operation to perform is a reset of IIS for the feature to be used on any new Team Sites that are created. NOTE: There may be other ways to do what I have shown in the post but most that I have found require some programming which may not be optimal in some environments. If you find a better way or even another way of doing this please send me an email and let me know.



1 Response to Automatically Turning on the Publishing Feature on a SharePoint Team Site
Hi, I've tried this on 2 completely different MOSS servers including 1 running MOSS SP2 and it doesnt work. It activates publishing but changes the site to a Site Directory instead of a team site.
Something to say?