Sunday, July 30, 2006

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

In an earlier post, Shane Young mentioned that the "Save site as template" link is only available under the Look and Feel menu of Site Settings at the Top Level of the site collection in WSS v3/MOSS 2007 Beta 2.  For all subsites, Shane advises to append “_layouts/savetmpl.aspx” to the URL in order to get to the Save Site as Template page.

Shane surmises that the missing link will be corrected by Microsoft post Beta 2, but in the meantime this omission poses a basic opportunity for developers to work with the new Features framework of WSS v3.  A new custom feature could enable site administrators to add a ‘Save site as template’ link to the Site Settings page of any WSS v3 site.

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.


<?xml version="1.0" encoding="utf-8" ?>

<Feature Id="DE98E72D-80FF-4031-88B0-2E4DEF6312C8"

       Title="Save Site As Template"

       Description="Adds a 'Save Site As Template' link to the Look and Feel menu in Site Settings."




       xmlns="" >


               <ElementManifest Location="Elements.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.


<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="">






       Title="Save site as template">

               <UrlAction Url="_layouts/savetmpl.aspx"/>



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.


New Link added by Feature

Categories: , , , , ,

Post a Comment