So I asked the question. How do I take a site that was created with the out of the box Team Site Definition and change it to use my custom definition (that is based on the team site definition) to that site? The only answer I was ever given was you can’t. I was then told I need to create a new site and then manually migrate all of my content. No thanks!
Well, since I didn’t know any better I started digging around on a way to modify the site definition. How hard can it really be? Well, turns out that it is not very hard to do. Ok first I will give you the short version then I will follow up with detailed instructions.
The short answer. Take the site you want to change, save it as a template, modify the manifest.xml inside of the STP file, resave the file, import the template, and create a site from the template.
Now I realize that is about worthless as directions. I just like to give the easy answer so you know where I am going. Kind of like the way I was supposed to write those term papers in college. I am still pretty new to site defintions and xml or caml or camels for that matter so I would love to hear feedback from those of you in the know. Is there something fundamentally wrong with this approach? Is it breaking something I don’t know about?
I have done some investigating and I have tried to grasp what is going on with this whole process. It looks sound to me as long as a few items are true about the site definition you are going to and from. To the best of my testing this will only work if the onet.xml file that you used in your new definition only contains additions to the onet.xml from the original.
The production scenario where I used this was where the modifications from the base template were all additional lists and modules in the onet.xml and minor file reference changes and web part zone additions in the default.aspx. I plan to test other modifications to see how far you can push the definition and still successfully update the site. So your results may vary.
Another problem we encountered is that if the site is larger than 10 MB you can not save as template. If this is the case you can then use FrontPage. Then you will have to change the root fwp file to cab and continue the instructions. When you finish the modification rename the file back to fwp. If you aren’t familiar with backing up and restoring a site with FrontPage check these instructions. http://www.microsoft.com/technet/prodtechnol/office/office2003/maintain/bureswss.mspx#EDAA
So before you continue be sure to understand I in no way support these changes or claim to be an expert on site definitions. If you wish to use the procedures be sure to make a backup first of everything and then try it in your test environment. (Yes, I know nobody will do this but I feel better reminding you to.) Ok, without further delay I give you the long answer.
Before we start we need to get a couple of questions answered
First we need to find the file that defines your custom site definition in the folder
C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\1033\XML
I used webtempCD.xml for my custom definition but yours will be different.
Once you find the file open it with wordpad
We want to find 2 answers
#1-What is the Template Name and ID? To do this we look at about the 5th line and you should find
<Template Name=”CustomDefName” ID=”50″>
Answer 1a is CustomDefName and 1b is 50
#2- What is the configuration ID for the configuration we want to use?
<Configuration ID=”0″ Title=”Custom Team Site” Hidden=”FALSE”……
<Configuration ID=”1″ Title=”Custom Blank Site” Hidden=”FALSE”……
<Configuration ID=”2″ Title=”Custom Document Workspace” Hidden=”FALSE”.
We want to apply the Custom Team Site so our answer is 0
Answer 2 is 0
Now we have our answer we can plug in the information later.
Lets create a site template of the site in question that was created with the standard team site definition. (Remember if your site is larger than 10 MB you need to use FrontPage, the instructions are above.)
Open the site in SharePoint
Click site settings
Click site administration
Click save as a template
Enter a filename and template name
Click Include content
When you get the operation successful message click go to site template gallery
Now click on the filename and save it to your desktop
Now rename the file from filename.stp to filename.cab
Extract the Manifest.xml (and any other files in the cab) to a new folder
Open the manifest.xml file with wordpad (or your XML editor of choice)
The 8th line should be
We need to change this number 1 to the number from question #1b above
So in the example we will have
Now we need to look at line 9
We need to change this to the answer from # 2 above
So in the example we will have
Now we need to do a find and replace on the template name. Our template name is answer #1a from above which is CustomDefName
The easiest way to do this is do a find for 1033\STS and replace with 1033\CustomDefName (If you started with a custom def then you will have something other than 1033\sts for the find. Replace sts with your old custom def name)
Now we need to save manifest.xml back to the folder we created that contains all of the extracted files (this may be the only file in the folder depending on the type of content you had in the site).
Now we need to package all of these files into a new CAB file. Use these instructions to create the CAB file
Now take your cab file and rename it newcabfile.stp
Now import the file into your site gallery
You can now create a site based on that imported template. And if you did everything correctly you will have the same site content as before but you will be using the new site definition.
Let me know what you think