Wednesday, January 7, 2009

Adding a 'Save site as template' Link to Site Settings in WSS v3/MOSS 2007 using a CustomAction Feature



The SaveSiteAsTemplate feature will consist of a Feature.xml and an Elements.xml file.
Feature.xml declares the Feature itself, and Elements.xml further defines the CustomAction for the Look and Feel menu on a Site Settings page.
To get started, create a folder named SaveSiteAsTemplate below the Features folder located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES on your WSS v3 server. Create Feature.xml and Elements.xml from the code below and place each file in the SaveSiteAsTemplate folder you just created.

Feature.xml



Note the Scope attribute in the Feature element of Feature.xml. Scope can be set to either Farm, WebApplication, Site or Web. Also notice that the ElementManifest element points to Elements.xml.

Elements.xml







Setting the Location of the CustomAction to Microsoft.SharePoint.Settings and the GroupId to Customization is what decides where the link will be render in the UI.
Next, install the feature into WSS v3 by using the stsadm tool. Stsadm.exe is located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN on your WSS v3 server.
stsadm -o installfeature -name SaveSiteAsTemplate


Finally, activate the new feature on your WSS Site by going to Site Settings > Site Features and clicking the Activate button for the new Save Site As Template feature.





You should now see a “Save site as template” link under the Look and Feel menu of the Site Settings page.








No comments: