Monday, February 26, 2007

WSS v3 Drop-Down Menus in Team Sites

While working with some custom site definitions based on the built-in STS (Team Site) definition I came across an annoying navigation issue that derailed me for a couple of hours. It turns out the the drop-down functionality in the top navigation bar, which works perfectly well in the Publishing and Collaboration Portal definitions, is disabled in the Team Site definition. After digging around in the object model for a while and trying a few different combinations, I found the solution in the menu settings contained within the default master page.

To enable drop-down menu functionality, locate the following block of code in the Default.Master page (/_catalog/masterpage/default.master in the site collection or \12\Template\Global\default.master on the file system):

< asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SPNavigationProvider"
id="topSiteMap"
runat="server"
StartingNodeUrl="sid:1002" / >

This sets the data source for the menu control and its associated parameters. Each Site Map Provider is defined in the < Providers > section of web.config. The SPNavigationProvider entry looks like this:

< add name="SPNavigationProvider" type="Microsoft.SharePoint.Navigation.SPNavigationProvider, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" / >

If you locate this entry in web.config you will notice another entry for "SPSiteMapProvider" immediately below it. After much trial and error I discovered that this is the data source that is required for the drop-down menus. To enable it, change the SiteMapDataSource settings in default.master (or your custom master page) to the following:

<asp:SiteMapDataSource
ShowStartingNode="True"
SiteMapProvider="SPSiteMapProvider"
id="topSiteMap"
runat="server" />

The navigation menu will now use the SPSiteMapProvider data source which contains all the nodes in the current site collection. Depending upon your requirements, you may also wish to modify the settings for the default number of static and dynamic levels (flyouts) the navigation control displays. To do that, adjust the following settings within the < SharePoint.AspMenu / > control:

StaticDisplayLevels="2"
MaximumDynamicDisplayLevels="1"

Adjusting these values up or down will increase or decrease the number of levels. Be advised that setting the levels to a higher value may impact performance, as the control will need to fetch the relevant information from the database and build the complete menu structure before the page can finish loading.

Saturday, February 17, 2007

Multilingual Scenarios

During the European SharePoint Conference this week I spent some time in a workgroup focused on multilingual scenarios in SharePoint and talked a great deal about these issues with other attendees. As you may already be aware, Microsoft's solution for portals supporting multiple languages is Site Variations, a process that allows for content duplication between source and target sites and automatic redirection based on browser localization settings.

Essentially, Variations act as an advanced form of replication. A publishing site is created and assigned as the source (the base language is irrelevant). Whenever a subsite is created, the administrator selects the site language pack and localization (such as US or UK English) and the site is then provisioned as a target. Whenever content in publishing controls on the source site is modified, the content is replicated to the target sites and, once approved, published for viewing.

While this is a good first step, there are a number of shortcomings to the Variations model. For one, it only applies to content in publishing controls - no lists, web parts, or other content is replicated. In addition, there is no translation performed during the replication process - it is incumbent upon a human being to at some point perform content translation into the target language. Finally, it does not provide a single portal - by which I mean a single, unified URL - to be presented in multiple languages; visitors are simply redirected to a target site (for example, from www.example.com to www.example.com/en) if one exists that matches their localization settings; if not, no redirection takes place.

In the multilingual working group we identified these as the top three items of concern out of a list of maybe ten or eleven issues (including search optimization, metadata translation, post-provisioning language reassignment, and more). From this, the group formulated some ideas on how to introduce features in the next version, or provide add-on solutions in the interim, to address these problems. As this is an important area of concern for our customers, we are giving serious consideration to developing our own suite of tools and utilities for multilingual portals. Before we go down this path, though, we need more information from the SharePoint community. We'd like to know how you are dealing with multilingual issues, what your top pain points are, and what form you'd like to see potential solutions take (web parts, custom site definitions, a packaged set of features, etc.). So talk to me - post some feedback (in the language of your choice, of course) and let me know what we can do to make your (multilingual) life easier.

Thursday, February 15, 2007

European SharePoint Conference Final Thoughts

The European SharePoint Conference in Berlin concluded with another full day of presentations. Previous commitments had me traveling back to the UK on Wednesday so I can't give a recap of day three (see here and here for a rundown on days one and two), which is really a shame as Ben Robb was scheduled to give a couple of good presentations on Internet-facing web sites and profiling/personalization that I would have liked to have attended. So instead here are my final thoughts on the conference as a whole.

Organization

The overall event organization was quite good. Check-in was a breeze, there were big signs in each area detailing the day's events, and if you got a bit lost all you had to do was grab hold of one of the ubiquitous orange-shirted emissaries to point you in the right direction. The sessions were a bit spread out due to the configuration of the facilities but you had plenty of time between sessions to wander to and fro and numerous opportunities to grab some refreshments on the way. There were some glitches with invoicing and payment that had a few people (including myself) scrambling a bit but I understand that was due to some EMEA regulations regarding credit-card bookings that were out of the organizer's control.

Content

I was quite pleased by the content presented in the break-out sessions. There was a distinct division between developer, IT and partner sessions, and quite a bit to choose from in each track. Naturally, the developers wanted to see more code and the IT people wanted more numbers, but that's always how it is. Aside from a few last-minute speaker substitutions most of it went off without a hitch.

Venue

The Hotel Estrel is a nice facility with lots of space but it wasn't laid out that well, especially for the vendor booths, forcing participants to walk back and forth across the hotel quite a bit. Guest rooms booked up quickly so a lot of people stayed at hotels scattered around Berlin (I chose the Upstalsboom Friedrichshain which was quite nice but, like everywhere else, had no WiFi to speak of). The staff were very good, exhibiting the renowned German efficiency - you could barely set an empty plate down before someone came and whisked it away. The food was mostly standard conference fair but I must say that the sweets were top notch - I had way more of them than I should have.

Speakers

There was quite a good mix of speakers for this event, even though some, like Patrick Tisseghem and Ben Robb, presented multiple sessions (which is fine by me because I like listening to them both). Speakers seemed to be matched well to their topics and generally provided good domain knowledge. The slide decks were fairly uniform (excepting Patrick, who seems to be as addicted to PowerPoint SmartArt as he is to Belgian beer) but there were lots of demos and code samples to keep things interesting. In fact, it will be a bit of a letdown when we get the final slide decks as most of the good content was in the demos.

Vendors

There was in impressive number of vendors at the event from all over Europe as well as the UK and America. Some were promoting general offerings - like HP and AMD - but there were a large number of SharePoint-specific solution providers in attendance. I didn't hang around the booths much so I don't know how good their conversion ratios were but there were a lot of people carrying literature and chatting up the vendors. The best venue for them was probably the vendor breakout sessions, of which there were quite a few, and which seemed to have pretty good attendance.

Participation

Quite frankly, I was amazed at the turnout for this event. Official figures were somewhere north of 2,300 participants. Considering all the other products that Microsoft has launched in the last year and the fact that SharePoint is marketed as part of the overall Office product line, this is really and astounding level of interest. If there were any doubts that SharePoint should be taken seriously this should dispel them entirely.

Conclusion

Like any event of this type, it wasn't perfect, but I think overall I'd give it a B+. The location was a bit difficult to reach for a lot of attendees (Paris, London or Rome would have been easier) but it wasn't too bad. The organization and content were good and the participation was excellent. I hope that next year will see an even greater number of attendees and more focused breakout sessions (and, of course, more in-depth developer content).

Wednesday, February 14, 2007

European SharePoint Conference, Day 2

After the previous night's entertainment we were all a bit bleary eyed come Tuesday morning (I probably looked the worst as I stayed up late blogging and then fought with the worst pillows ever created in the history of mankind in a losing battle for even a few hours of sleep). But with a healthy dose of coffee and a can-do attitude (or, more accurately, an I'm-awake-so-I-may-as-well-make-the-best-of-it attitude) I dived back into the conference.

Designing, Deploying and Managing Workflow in SharePoint Sites (Christian Stark)

The toughest part of a conference like this is choosing which sessions to attend. There were a large number of presentations from partners and ISV's that I would have liked to have taken in but I concentrated on the Development track as best I could since that is our core business. Unfortunately, this presentation was just a click-n-show overview with no code and I think I dozed off somewhere in the middle. From the parts I do remember, I recall Christian pointing out that while you can author workflows for WSS sites you have to buy MOSS to get any built-in workflows or workflow templates (I wasn't aware of that). He also said that there will be a workflow SDK coming out soon that will have a bunch of workflow templates included with it. Hallelujah!

I realized later, after talking with Dr. Ulrich Knechtel of AMD, that I should have gone to his presentation about their search optimization project with Microsoft. The two companies are teaming up to create hardware/software configurations optimized for large-scale search optimization. If you've ever worked with search in a big deployment you know how resource-intensive this process can be so this new initiative looks very promising (post a comment if you want more information - they're looking for customer projects that might serve as good POC's).

Developing Visual Studio Workflows and Activities for SharePoint Sites (Steve Heaney)

Now this is what I came for. Steve got down and dirty and showed us how to code up workflows from scratch in Visual Studio. It was one of the most amazing demos I've ever seen - Steve hand-coded a five step WF, including two custom InfoPath forms, in a half-hour, without making a single mistake. In fact, he never even used Intellisense - just whipped out some classes, slapped in some methods, banged the code in and pressed F5. Build succeeded the first time! Unbelievable. Obviously, Steve had done this presentation many times before but it was still bloody impressive.

If you haven't played with it yet, the workflow designer in VS 2005 is really quite good. There are a bunch of built-in workflow objects that you can drop in from the toolbox and creating your own is almost as simple as whipping up a Visio diagram. What Steve didn't cover (due only to time restrictions, I think) was coding custom actions and activities, which is the real meat of VS and WF. In most cases, designers will create the workflows in SharePoint Designer with custom activities supplied by developers, as the VS method is much too complex for your average front-end person. That said, you can do a lot with it and it's very flexible and extensible.

Capacity and Performance Planning (Steve Smith)

The Combined Knowledge booth was the unofficial UK gathering point at the conference. We joked about hanging a Union Jack from one of the columns and I think we would have done it had anyone thought to bring one. Steve Smith, MVP with Combined Knowledge, gave several presentations but this was the first I one I could fit into my agenda. Steve derived a great deal of his content from Joel Oleson's blog and put up some useful figures from this post. Although I dispute some of his assumptions (he uses a 10% utilization baseline for concurrency which I believe is way too low - but it really depends on how each portal is used) and conclusions (40% of latency issues are at the client? I really don't think so - better check those capture stats one more time, mate), Steve did quite a good job painting a realistic picture of scalability issues and areas to look for performance issues.

At one point, Steve illustrated the issues regarding list rendering as it relates to item count by showing a line graph (shaped like a hockey-stick) of the per-transaction completion time of a document add operation in a library. The more documents you add (I think the tipping point was around 2,000) the worse the performance gets - way worse, in fact. I couldn't have asked for a better visual describing the limitations of using the object model for repetitive operations (he didn't say but I'll bet my hat they used the OM to do it). I can't wait to get my hands on that slide so I can demonstrate the stark difference in performance when executing the exact same operation using web services or FrontPage RPC's.

Speaking of slides, Steve hit us with so many statistics that I can't possibly hope to reproduce them all here (and I was scribbling like a madman so I probably got most of them wrong anyway). As soon as Steve uploads the presentation I'll post them all here - they really are important data points to consider when planning your farm deployment and/or expansion. For example, one thing that never occurred to me when troubleshooting performance is the relationship between your MOSS server farm and Active Directory. If you have several thousand users on a portal the new security-trimming features require a lot of authentication procedures; enough to overload that poor old AD box sitting all by itself in a forgotten corner of the data center. One more place to look when your users suddenly start complaining about how long it takes to login to SharePoint in the morning...

Building and Branding SharePoint Sites Using New Web Content (Arpan Shah)

Ok, so this one really didn't include much development content (unless you consider SharePoint Designer to be a development tool) but it was good nonetheless. Unfortunately for Arpan, he had just returned from vacation and it seemed like parts of his demo were still on holiday - Designer didn't want to cooperate and his MOSS site was a bit flaky but Arpan's an excellent presenter and what he couldn't show he explained rather well. He did a fair job introducing site variations to the audience but it wa really only a warmup for the next Dev session.

Multilingual Portal and Public-Facing Web Applications (Aku Heikkerö)

It was fitting (and somewhat amusing) that the presenter for Multilingual solutions had a Finnish accent so heavy I could barely understand him. Where's that universal translator from the Tardis when I need one? In any event, you should know by now that this is an important area of interest for me, and Aku did a good job of digging into the ins and outs of site variations. He was also very explicit on what variations can and can't do (and even though they can do some good things they are just a small step towards solving this problem). One thing I didn't know (just because I haven't had time to play with the new MySites much) is that users can now pick the language they want to see their MySite in. That's very cool. After the presentation I mapped out some ideas on how to improve site variations to make them more usable in real-world scenarios (more on this in a future post) with my new friend Razvan-Petru Radu from Luxembourg. And no, in case you're still wondering from yesterday, no word yet on that Redneck language pack for MOSS.

Shared Emotions

I don't think I was the only one who thought this was an odd name for the after-conference party. Even more odd was being shipped by bus halfway across Berlin to a big warehouse on some island for a dinner party when we had a huge hall at our disposal right there at the Estrel (we all fit in there the night before, didn't we?). Thankfully, there were no celebrity impersonators, just a really lukewarm jazz band. Personally, I would have liked to see the guy who did the Louis Armstrong bit on Monday night do another set just to liven things up (I poke fun at the lookalike entertainers but they really were very talented). Rob Gray from Microsoft UK managed to secure the upstairs lounge for our lot so we enjoyed feeling superior to everyone else from on high. The food was spectacular, especially if you are a fan of creme brulee, and the beer and wine were free. Can't beat that!

Internet Access

Let's tell the truth here - trying to get to the Internet in Berlin was like trying to find a place to stand in the conference common areas where someone wasn't smoking. First of all, there was no free WiFi at the convention center. Only hotel guests could access the WiFi and they had to pay for it - not even the conference speakers had access to the Internet. Think about that for a second - a Microsoft conference about a purely browser-based product and no WiFi? Uh, pardon me for pointing out the elephant in the middle of the room, that's just plain ridiculous. My hotel and the airport were no better, with either weak signals that were all but useless or pay-as-you-go services that wanted upwards of 10 euros for 30 minutes of blissful connectivity. I know the Germans pride themselves on their efficiency but they've got a lot to learn from us Yanks on this score.

Notes on Berlin

It's a shame really that I didn't get to see much of Berlin at all on this trip. Being a history buff I could probably spend days wandering around the museums and such. I did learn that the airport that I flew into (Flughafen Tempelhof) was central to the Berlin Airlift operation and used to be a US Air Force base (it was the Americans, in fact, who built the current concrete runways). There's a statue out front dedicated to the US and British pilots who died during that operation - very cool. East Berlin is still a bit grim but there is a fair amount of new construction intermixed with some really old structures. There's a strange statue on the river of three figures fighting or wrestling - I'm not sure which - that I never did figure out and none of the cab driver spoke enough English to explain it to me. The real travesty of this visit was that I had precious little time to sample any German beer. That's almost a crime, I think, to visit Berlin and never set foot in a Biergarten.

Monday, February 12, 2007

European SharePoint Conference, Day 1

Today was the first day of the European (EMEA) SharePoint Conference in Berlin, Germany. As we have recently expanded into the UK, we are now officially a 'global' company (there's a scary thought for you) so we took this opportunity to join our mates from jolly ol' England on a jaunt across the Old Country. I have to say that I am quite impressed by the overall experience - if there were any doubts that SharePoint is a serious application around the world, let them be dispelled here and now. With more than 2,300 attendees (that's nearly twice as many as we managed to cobble together in the States last year) from 40 countries and 90 partners and vendors, it was quite a show. Read on for a summary of the day's events.

BTW, Southwest could learn a few things from SN Brussels Airlines. Like, how about some free chocolates on each trip instead of crappy peanuts, eh Mr. Kelleher?

Opening/Keynote

The Microsoft team kicked off the conference with a five-minute introduction in German (to the delight of the local audience, I might add) which left most of us scratching our heads and saying 'Was is das?'. The 'Wow is Now' video has long since jumped the shark, but the first speakers were energetic enough to make up for it. The catchphrase of the day was 'Ich bin ein SharePointer'. Say that a few times after a couple of Hefeweizen!

Derek Burney

There were quite a few Redmondites around - especially on stage and in the ubiquitous orange speaker shirts - and Derek Burney was first up (with an able assist from Mike Fitzmaurice). He laid some good numbers on us, like license count now exceeding 80 million worldwide and the official size of the internal Microsoft SharePoint deployment: 325,000 portals, sites and subsites comprising more than 12TB of data (who gets to back that up, I wonder?). It was interesting to note that on his slide promoting 'major' companies who had adopted SharePoint, three of the ten are based in Dallas :-)

Mike revealed publicly what had heretofore been confidential, so I can now tell you that sometime next month MS will unveil the official SharePoint Community Portal. Lawrence Liu gave us a rundown of this last week at the UK SharePoint User Group meeting (what, you weren't there?) and it's plenty slick. Just a beta right now but it will be live soon.

They closed with the most ridiculous commercial I've ever seen - a takeoff on those Total cereal ads where they claim that everything and the kitchen sink is in 'just one bowl'. It came complete with a corny jingle and sleazy used-car-salesman actor. Ok, I get the message, but was this really a good use of marketing dollars? Really?

Patrick Tisseghem, Part Eins

I always enjoying listening to Patrick as 1) he knows his stuff, and 2) he's a good presenter. And you just gotta like a guy whose every demo has something to do with beer. Patrick gave the standard rundown on using the object model, talked about garbage collection and good coding practices, and highlighted a bit about working with web services. He covered impersonation pretty well, which I think was lost on most everyone present, and even talked a bit about CAML and SPSiteDataQuery. Although he gave an explicit warning about using the DataQuery object to collect list data instead of looping through the SPListCollection, he did not voice similar concerns about using the object model to loop through SPWeb objects. In fact, he showed us how to do it (albeit briefly) and moved quickly past it.

I suppose I'm destined to be the lone voice in the wilderness on this issue, so let me state it once again in case anyone missed it the first thousand times - DON'T DO THIS! EVER! Unless you know for a fact that you'll never have more than a hundred or so sites in a site collection, this is bad, bad, bad. The overhead of GetSubwebsForCurrentUser and its equivalent(s) is tremendous and should be avoided like the plague. I know that's how it's shown in the SDK but you don't believe everything you read, do you?

Multilingual Working Group

Aside from the bizarre evening entertainment (see below) this was the highlight of the day. We don't think much about it in the States but this is a real pain point for many customers, especially throughout Europe where they often have to support three, four, five or a half-dozen languages at once. Hats off to Microsoft for realizing the severity of the issue and soliciting feedback and advice from partners and users. A couple of partners and myself gave 'em an earful for an hour (I also harped on Lawrence about this last week, so if you're reading this Al, that one's for you!). We came out with some good ideas and even a few suggestions for the workgroup sponsors to take back to Microsoft. We also agreed that since C# seems to be a universal language we are all now adding it to our resumes (CV's) immediately. And no, in case you're wondering, there is no Redneck Language Pack forthcoming in this or any future release, so y'all will have to just go on scratchin' yer heads at my vocabillary.

Content Types and Metadata

Good topic, wrong audience. This was supposed to be on the developer track and although Dustin Friesenhahn gave a good presentation it was all foam and no beer. There were only a couple of slides that even showed a smattering of code - the rest was all point and click. Nice for the IT guys but not what we hardcore OM types were looking for. General disappointment was expressed by all.

Patrick Tisseghem, Part Zwei

After that letdown, we needed some real code to perk us up, and Patrick didn't let us down. Some genius assigned him the topic of Templates, Definitions and Solution Deployment and only gave him an hour - now that's just plain wrong. I could talk for an entire day on any one of those subjects and I don't have all of Patrick's demos and SmartArt. He did an admirable job walking the group through custom site definitions and deployment - not an easy topic even for intermediate coders. Lots of great code samples and the ever-present Beer Team site.

Dinner and Entertainment

The Hotel Estrel Convention Center is reminiscent of Vegas-style auditoriums - lots of multimedia and light shows. After Patrick's final presentation a swarm of worker bees descended upon the room and cleared more chairs in five minutes than were on the entire deck of the Titanic. There's something to be said for German efficiency. While we all wandered off for a beer or two (konnte ich Schofferhofer bitte?) they turned out the 'rounds and we piled back in for some free victuals. I can't say much for the food - it was typical bland conference style fare meant not to offend anyone - but when the lights went down after the meal things go interesting.

Turns out the Estrel is the home of a popular Vegas-style musical review called Stars on Stage. Before we knew what was happening, a pre-Bobby Brown Whitney Houston was belting 'em out on stage, complete with scenes form her music videos and the requisite clips from Bodyguard during 'I Will Always Love You' on the big screens. Without a chance to catch our breath (or keep from falling over with laughter) were were hit in succession with Madonna, Boy George, Louis Armstrong, Tina Turner (who looked awfully like Whitney in a different wig) and finally, as you would expect, Elvis himself. I'll give 'em this - they were pretty damn good, especially considering they didn't have the best acoustics to work with and a stage with no Vegas flair (but some might fine-looking backup dancers). Louis Armstrong was simply amazing - right down to his facial expressions and the gap in his front teeth, this guy has it down, you dig? And all of this with a gigantic Office SharePoint Server 2007 sign in the background. Now don't that beat all?

So that's a wrap for day one. I'll post pictures as soon as I can get a reliable WiFi connection (don't even get me started on Internet access over here). And before I collapse for the night, a hearty "Salut!" to my new friends from Romania, Reka and Marius, and "Moien" to David and Razvan from Luxembourg.

Gute Nacht!

Friday, February 02, 2007

Creating a Basic Site Definition in SharePoint 2007

Creating a site definition from scratch in SharePoint 2007 is no easy task; easier, certainly, than it was in 2003, but in some ways even more complex. Perhaps the most confusing new element to creating site definitions is the use of FEATURES. There are some great articles on what FEATURES are and how to use them (see here, here, and here) so do a little homework before you get started.

Unfortunately, the built-in WSS templates don't use the time-saving and oh-so-handy Publishing features of the portal definitions, so you'll have to create your own definition if you want to apply any customizations beyond basic style overrides. To get you going in the right direction, here's a handy little guide on creating a very basic site definition from scratch. Let's first assume that you want a custom Team Site - nothing fancy, just something you can style and modify without impacting the default definitions.

Begin by performing the same steps you would have done in 2003. Navigate to the \12\Template\SiteTemplates directory (the 60 hive is dead; long live the 12 hive). Copy the 'Sts' folder and rename it - say 'CUSTOMSITE' for this example. Next, find the WEBTEMP.XML folder in \12\Template\1033\Xml. Open it in Notepad and add a new Template node to the end, like so:

< Template Name="CUSTOMSITE" ID="1001" >
< Configuration ID="0" Title="Custom Web Site" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" Description="Customized site definition for My Team Site" DisplayCategory="Collaboration" > < /Configuration >
< /Template >

* Note: The same numbering conventions apply in 2007 as in 2003 - set your Template ID to something greater than 1000 and the first Configuration node should always start with '0'.

Save the file and do an IISRESET at the command prompt. This is all you really need for a basic site definition but, as you will discover if you create a new Site Collection using this new definition and open it in SharePoint Designer, there are some things missing. Some very important things, actually, like the DefaultLayout.aspx page (look in /_catalogs/masterpage and you'll notice that only the default.master page is present). Without DefaultLayout.aspx you'll be able to modify the master page but not the central content area of your site. Oops. What happened?

As I said at the beginning, it's all about the Features. In this case, not only does the ONET.XML file determine what Features are provisioned as part of the site, there are also Features which determine what goes into a site that have nothing to do with the site itself - they are system Features that SharePoint uses when provisioning all sites.

To make sure that your new Site Definition has all the right pieces and parts, navigate to the \12\Template\Features\BaseSiteStapling folder and open BaseSiteStapling.xml in Notepad. It should look something like this:

< Elements xmlns="http://schemas.microsoft.com/sharepoint/">

< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="STS#0" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="STS#2" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MPS#0" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MPS#1" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MPS#2" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MPS#3" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="MPS#4" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="WIKI#0" / >
< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="BLOG#0" / >

...

Take note of the first child node - it defines a Feature (in this case, the BaseSiteFeatureTitle) to be included with the site identified by the TemplateName setting. Does this setting look familiar? It should, as it's the same as the STS (WSS Team Site) < Template > node in WEBTEMP.XML. The #0 after it refers to a specific < Configuration > child node. Since your new Site Definition needs to behave exactly as the STS definition does, you must create a < FeatureSiteTemplateAssociation > for each Feature that STS is associated with, like so:

< FeatureSiteTemplateAssociation Id="B21B090C-C796-4b0f-AC0F-7EF1659C20AE" TemplateName="CUSTOMSITE#0" / >

Simply go through BaseSiteStapling.xml and each time you see an ID associated with STS#0 add an entry for CUSTOMSITE. But wait, you're not done. You now have to do the same thing in the PremiumSiteStapling.xml file located in \12\Template\Features\PremiumSiteStapling folder and, if you want the included workflows, do the same in FeatureStapling.xml in \12\Template\Features\StapledWorkflows folder.

Perform another IISRESET and create a new Site Collection based on your custom Site Definition. Now, when you edit the site in SharePoint Designer, you will see all the right files in /_catalogs/masterpage, such as DefaultLayout.aspx, AdvancedSearchLayout.aspx, SearchMain.aspx, etc.

As an aside, you can mimic some of the Publishing functionality of the Portal Site Definitions by create your own Style and Images libraries, uploading your files, and referring to them from your customized master and layout pages by relative URL (such as ../../images/myhomepageimage.gif or ../../styles/custom.css). See this post for information on how to override CORE.CSS using this method.


kick it on SharePointKicks.com

Thursday, February 01, 2007

Overriding Default Stylesheets in SharePoint 2007

Heather Solomon posted a detailed explanation on her site regarding the inheritance of styles in MOSS; specifically, the various methods for overriding CORE.CSS in master pages and site definitions. After defining the various options, Heather recommends the following for applying custom styles:

My recommendation is to store styles in the master page itself in a set of STYLE tags. If your master page design has variations for assorted subsites, store the CSS differences in a file and reference it via the Master Page settings, or if you need CSS changes for a single page, store it in an HTML file and reference it in a hidden Content Editor Web Part.

I wasn't at all comfortable with this approach, not so much because there is anything wrong with it (there isn't and Heather should get an award for incurring the brain damage required to sort through it all), but mostly because I don't like the idea of SharePoint forcing a default style onto my customized pages, thereby making me jump through hoops to correct a deficiency that never should have been there in the first place. I thought we'd been through this enough with 2003 and the design team would have learned their lesson but apparently not.

So after playing around with a few alternatives, I went old school and found the solution. Instead of using one of the new < SharePoint:CssRegistration / > tags to register your override style in the header, simply place it in a classic ASP < link > tag in the same location, like so:

< link rel="stylesheet" type="text/css" href="../../Style Library/en-us/Core Styles/core_override.css" / >

This procedure will circumvent whatever the parser is doing in the background to throw CORE.CSS into the mix at all the wrong places. The beauty of it is that CORE.CSS is called before your override stylesheet so you can inherit all the default styles and only override the styles you need. Be sure that the relative path is correct for the site definition you are working with. An alternative would be to place your override into the same folder as CORE.CSS and use a fixed path, which would make working with different site definitions much easier, as each master page can point to its own override file (this can also be done programmatically).

UPDATE: As Shane points out in his comments on this post, using the alternate style setting in the site collection settings IS a reliable method for overriding CORE.CSS; however, there are some things you should consider if you are using this approach:

1) The alternate CSS setting is GLOBAl for the site collection. This means that all pages, including _layout pages, will inherit this style. That may work for one implementation and not another; you might want different styles for the Admin pages (my term for all the pages found in _layouts), content pages, or subsites.

2) The Alternate CSS setting applies to all subsites in the collection, making it more difficult to assign those styles programatically. If you want to mix and match styles in your subsites you will have to find a method to override both CORE.CSS AND the alternate style.

3) The alternate setting must be done AFTER the site is provisioned. This obviously won't work for custom site definitions. A better approach would be to put the style in the master page settings, the PlaceHolderAdditionalPageHead, or, as I have suggested, use a <> tag.