Monday, October 26, 2009

A little something I'd forgotten- addtemplates. (when you absolutely positively have to have that template handy...)

So, I've travelled all over the US doing presentations about WSS 3.0, and particularly things that stretch the boundaries of the out of the box capabilities of WSS without spending a penny.

One of the sessions is a follow up about creating a site template out of the nifty site that had been modified and made more useful in the previous sessions. It showed the pros and cons about site templates, some of the things that need to be considered, etc..

Now when you create a site template, it is made into a template file, or package, with the file extension .stp. Site templates were meant to be added to particular site collections where you'd like the template to be available.

Therefore, it stands to reason that site templates would not normally be available to be used for the first and top level site of a site collection-- because the site collection must already have a top level site in the site collection to have a site collection gallery to put the .stp file in.

However, there is a work around.


Did you know that you could use the "STSADM -o addtemplate" operation to allow any site template to be available as a top level template? Yup. Not only that, but if there is a site template you'd just like to have available everywhere without having to add it to each site collection's gallery, addtemplate is your friend.

It is a farmwide, or global operation, meaning that the template is added to the farm and is available for every web application and every site collection within those web apps. So top level to bottom most subsite, the template would be available.

To add a site template to the farm so it will be available everywhere, including to be applied to top level sites, use the STSADM -o addtemplate command (here's the command syntax and parameters):

STSADM -o addtemplate -filename -title -description

So, in my case I'd like to add the User Group Edition site template from the SharePoint Community Kit from Codeplex (codeplex makes free stuff for the community). I've always liked that site, for numerous reasons, but have not liked that, to use it, I needed it to be a subsite of an existing site collection. I'd like to take that .stp file and make it available as the first site in a site collection I can dedicate to a user group.

So first I, moved the stp file to my C: drive for easy access. Then I opened a command prompt and navigated to the bin folder in the 12 hive where STSADM is kept.

Then I typed in the STSADM command that would add the user group edition template I like so much (cks_uge_1.0.stp) to the global templates available for the whole farm. I am also going to add a title (remember the title) and description (remember that, for the sake of this demonstration, I put the template in the root of the drive):

STSADM -o addtemplate -filename "c:\cks_uge_1.0.stp" -title "User Group Site" -description "User Group Edition site template"

After running the command I was prompted to do an IISRESET, which I did (I like doing iisreset /noforce, but that's just me).


Now that the template has been added globally to the farm, I can create a site collection in any web application within the farm and the template will be there. That means that I can apply the User group edition template to the first site in a collection.





To delete a template you only have to specify the title:

STSADM -o deletetemplate -title "User Group Site"

Somethings to note-- don't delete a site template that's being used, it can cause issues. Don't delete a site template and then try to add it back-- it can cause errors as well.

Over all, measure twice, cut once. Only add templates you don't intend on ever removing, and remove them with caution.


I also rather like the simple little timecard template that Microsoft offers as part of it's Fantastic 40 templates. I often add it to site collections so I can tack it on to demos and examples as I go.

To avoid having to keep adding the file to each site collection's gallery (and having to remember which site collection already had it), I just did an add template with it:

STSADM -o addtemplate -filename "c:\apptemplates\timecardmanagement.stp" -title timecard -description "Site to track hours and tasks"


After that (and an IISreset) I could easily go to any web application on the farm, and any site collection in those web apps, and easily select the template to apply to any subsite (or top site for that matter) that I wish.


If you ever need to check to see what templates you've added to the farm, you can do:

STSADM -o enumtemplates


Which will show you what templates you have available (this screenshot, like the one above, is from a similar deployment, but it's not identical, the UGE template is "UGE" here and not "User group site", for those of you watching closely).

I want to give a shout out to Mario Fulton (who is a Microsoft Certified Master in SharePoint 2007), out of Columbus, who so kindly mentioned adding templates globally after attending one of my sessions at a Columbus. I had totally and completely forgotten about it. He was a kind and generous guy, who was extraordinarily gracious in mentioning the command (which, among other things, I didn't have time to talk about), rather than shouting it out during an already busy session and playing stump the speaker.

3 comments:

Jennifer said...

Excellent post, Callahan!

I frequently tell my SP users about your "Frugal Admin" series.

I hope that you are feeling better. and I look forward to reading your posts about SP 2010.

Callahan said...

Thanks Jennifer!

I appreciate the shout out to your users.

I find it hard to get any training with frugality in mind. Usually it's only on the more expensive version of the product, complete with even more expensive add-ons.

I also find it hard to get any training on either just WSS or at least the basics anymore. Thus I write this stuff, and do the "Frugal Admin" series.

It's really nice to hear that someone appreciates what I'm doing. Thanks.

James said...

You know--someone should write a chapter in a book about this. Oh wait--they already did. :)

I hope you start feeling better CA!