February 2006 - Posts
Now that my 6 month hiatus from training is over it is back to business as usual. (Wonder if that 6 months coinciding with SharePoint911’s 6 month anniversary has anything to do with each other?) I will be teaching SharePoint Solutions Jumpstart course in Chicago March 7th through the 9th. Sign up and more information available here. This course is geared toward a technical audience and was actually my first exposure ever to SharePoint. J Now I am an MVP and the trainer. (Your results may vary.)
Teaching is without a doubt my favorite part of this job. To be honest if everything in life paid the same I would be a high school teacher and a volleyball coach. So I am very excited to be returning to the classroom. Hope to see you there.
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
So in our last article on site definitions we discussed how to create a site definition that creates a picture library. And within that library we add an image that we wanted to be the default site logo. Now we need to make one modification to our default.aspx to force the site to use our logo on the home page. If we open the site we need to find the <!--Title--> section and change the section below in bold.
<!-- Title -->
<tr> <td colspan=3 class="ms-titleareaframe"> <div class="ms-titleareaframe"> <table width=100% border=0 class="ms-titleareaframe" cellpadding=0 cellspacing=0> <tr> <td style="padding-bottom: 0px"> <table style="padding-top: 0px;padding-left: 2px" cellpadding=0 cellspacing=0 border=0> <tr> <td align=center nowrap style="padding-top: 4px" width="132" height="46"> <img ID=onetidtpweb1 src="SiteImages/wpd.gif" alt="Icon" height="49" width="49"> </td> <td><IMG SRC="/_layouts/images/blank.gif" width=22 height=1 alt=""></td> <td nowrap width="100%" style="padding-top: 0px"> <table cellpadding=0 cellspacing=0> <tr> <td nowrap class="ms-titlearea"> <SharePoint:ProjectProperty Property="Title" runat="server"/> </td> </tr> <tr> <td ID=onetidPageTitle class="ms-pagetitle">Home<!-- --></td> </tr> </table> </td> <td align=right valign=top> <table cellpadding=0 cellspacing=0 height=100%> <tr> <SharePoint:ViewSearchForm ID="L_SearchView" Prompt="Search this site" Go="Go" Action="searchresults.aspx" runat="server"/> </tr> <tr style="padding-right:1px"><td colspan=5 nowrap style="padding-bottom: 3px; padding-top: 1px; vertical-align: bottom" align=right class="ms-vb"> <span class='ms-SPLink'> <span class='ms-HoverCellInActive' onmouseover="this.className='ms-HoverCellActive'"; onmouseout="this.className='ms-HoverCellInActive'"> <WebPartPages:SettingsLink runat="server"/> </span> </span> <WebPartPages:AuthenticationButton runat="server"/> </td></tr> </table> </td> </tr> </table> <table cellpadding=0 cellspacing=0 border=0 width=100%> <tr> <td class="ms-titlearealine" height=1 colspan=5><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td> </tr> </table> </td> </tr> </table> </div> </td> </tr>
<tr valign=top height=100%>
<!-- Navigation -->
That is it. Now if your users want a new site logo all they have to do is replace the file in the picture library.
You will also notice that by default SharePoint resizes the picture to 49 x 49. We played with sizing and ended up modifying this to take up the whole space.
1 more article to go and then I will leave the CAML alone. He smells funny so I will not miss him.
Microsoft did some testing to see what kind of performance you get by use SQL 2005 instead of SQL 2000 on 64bit hardware. Interesting results. I have some other thoughts but I will hold them for now. How about you? Any comments you want to share?
Mart has a nice link to this word doc that is essentially a list of commons support questions for WSS and the way fix the problem. Very nice find!
Ok so I had a fun week learning how site definitions really work. Wow! Very cool stuff, now I see why so many of you get lost in there and never come out. Thankfully I am back to portal search problems next week and I can escape CAML and the 1,000 fleas that come with it.
Before I return to the safety of SharePoint portal infrastructure, extranets, and taxonomy design I will leave you with three articles that are hopefully fresh ideas on things to do with the animal that can go weeks without water.
So the request was to come up with a way to have the logo in the left hand corner of a WSS site display a logo from a picture library. This way the users could just replace the file in the library to add their own custom logo to their site without using FrontPage. I decided to tackle what I thought would be the hard part first. How to modify the already custom site definition so that all future sites that are created would have this functionality. We will worry about the existing sites later, in article # 3.
After doing some googling I couldn’t find a good answer. So I dove head first into the admin guide followed by the SDK and made up my own solution. After looking at how the onet.xml file works I realized I need to create 3 new modules to create files and then have my configuration call those modules.
So below the module
<Module Name="DefaultBlank" Url="" Path="">
….lots of xml
I created 3 new modules as so:
<Module Name="SiteImages" List="109" Url="SiteImages" Path="DOCTEMP\A">
<File Url="wpd.gif" Type="GhostableInLibrary"/>
<Module Name="SiteImages1" List="109" Url="SiteImages/_t" Path="DOCTEMP\A\t">
<Module Name="SiteImages2" List="109" Url="SiteImages/_w" Path="DOCTEMP\A\w">
I will try to explain how the siteimages Module works.
Name – This is the name of the module, you reference this in the configuration section to cause this section to be added.
List – In this case 109 is the code for Picture Library as defined earlier in the file
URL – This is where the files will be stored relative to the root of the site.
Path – This is where within the site definition it will retrieve the files from. I created the A folder under the DOCTEMP at the root of the site definition.
URL – Is the name of the file within the site as it is located in the SiteImages folder.
Type – I don’t really understand this part but without it the file does not show up in the library even though it is there.
I will not repeat for the other 2 modules but I will say this. Notice each module has its own name, and the url and path is different for each. The reason we need 3 modules is when you upload a picture to a picture library it not only uploads the file but it creates 2 preview images and puts them in hidden sub folders. Well, for our picture library to have the preview functionality available when we automagically create it we need to populate these preview images also.
Now you are probably wondering how do you get these preview images? What I did was go to an existing site and upload my image. Then SharePoint created the preview images. I copied them to my doctemp locations and I was good to go.
Just to be clear my directory structure was
And for some reason the 2 wpd_gif.jpg files were slightly different size. I figured I would just give SharePoint what it wanted and went through the effort to have 2 separate files.
Alright so now we know how to create files and where to get the right files from we need to look for where to tell the file to use our modules. For this we go up to the configuration section.
<Configuration ID="0" Name="Default">
………….. lots of xml cut out
This is what it looks like by default. We are just going to add reference to our 3 modules right below the module named “WebPartPopulation”
You should have something like this:
<Configuration ID="0" Name="Default">
….. Lots of cut XML
So this will force SharePoint to add our modules if you choose Configuration 0.
Only thing left is to now create that Picture Library called SiteImages so our files have somewhere to go. To do this we stay in the same configuration section. We are just going to move up to the <Lists> section we removed earlier. We will then just add another list item by inserting this code.
<List Title="SiteImages" Type="109" Url="SiteImages" />
And that’s all folks! If you create the directories in doctemp and copy in the files, then make these changes to your onet.xml you will get a picture library with a picture in it next time you create a site. And to make this easily reproducible I have included all of the files you would need. Go to HERE you can download the new onet.xml file and the images so you can try this in your test enivornment. I am also including a word document with the onet.xml text saved inside and all of the places where I added to the file are saved in green. I know sometimes it is easier to look at the real thing than to follow goofy instuctions.
Next article will be how to change the default.aspx file so you can reference this image as your site logo. Articel #2
Let me know what you think.
SharePoint Help from SharePoint911