Sitecore development 2.0

It’s been a while, but I’ve decide to write a nice post this hot sunday. It’s around the 30 degrees in Holland which doesn’t clear up your brains very efficient :P. There are clouds, the air carries has much H2o-molecules and from my head to my body, I stay sweating. Bleerrgggg ;). Had some sun this thursday, which causes me a red face and lots of jokes are made at the office(Thank you guys :)). The summer is about to start, but for me, at this moment, it may just end!
A small light at the end of the tunnel: 4 August till 11 August,you can find me in Sealand(the Dutch-one) just doing notthing, haging aroung with some friends, drinking beer, etc. Not really nerd-like, altough, it’s good for everyone to take some ‘rest’.

This post is not just about my personal problems with the incredible hot start of this summer. It’s also about Sitecore. Like you guys are used to. This post will be about a new way of development. Not a new way like changing from C# to VB.Net. No it’s more development based on experience. For the past one and a half year we have continiously been working on lots of Sitecore solutions. We’ve made design mistakes, we’ve been geniuses(genii), we’ve lost many expensive hours and we’ve created not workable datastructures. This doesn’t differ from any other project in the IT, right? We’ve decided to learn a bit from this.
With our team of (lead-)engineers, we are actually creating a kind of ‘best pratices’ on Development and CMS/Sitecore structures. We haven’t found it out for real. We don’t share them with each other, like you prefer we should share them, but this will come. No doubt.

Some of the improvements I’ve been talking about:
– Usage of own Context objects(with functions like ‘GetSiteSectionOfItem’, ‘AnchestorAtLevel’)
– Util function for default Content-actions (‘GetTitleOfItem’, which looks for the field Title else, it will display the ‘DisplayName’ or an impelementation like below)
– Default Sitecore XPath Query builders
– Taking all output of Sitecore data trough filters
For example: make an empty ‘ValidateLink’-method in a LinkUtil-class. Make sure, all links of the site, are validated by this method. When you have to change someting now, or in the feature, you just ahve to change it once.

/// <summary>
/// Get the title of a Sitecore item.
/// </summary>
/// <param name=”item”>The Sitecore item to get the title of.</param>
/// <param name=”checkDisplay”>Defines if the value in the Show title checkbox should influence the return value.</param>
/// <returns>A string containing title of the specified item or the name if no title was available. If the title should not be showed, an empty string is returned.</returns>
public static string Title(Sitecore.Data.Items.Item item, bool checkDisplay)
{
Sitecore.Data.Fields.CheckboxField ShowTitle = item.Fields[“Show title”];
return checkDisplay && ShowTitle != null && !ShowTitle.Checked ? String.Empty : Title(item);
}

/// <summary>
/// Gets the title of a Sitecore item.
/// </summary>
/// <param name=”item”>The Sitecore item to get the title of.</param>
/// <returns>A string containing title of the specified item or the name if no title was available.</returns>
public static string Title(Sitecore.Data.Items.Item item)
{
Sitecore.Data.Fields.Field Title = item.Fields[“Title”];
return Title != null ? Title.Value : item.Name;
}

The above code snap is written by one of my colleguess. He has lots of experience with MS CMS and related products(Sharepoint, CRM, etc), but Sitecore is/was new for him.

Datastructures:
We’ve found out that /news.aspx?nid={11111111-1111-1111-1111-111111111111} is a very ugly way to show your news. A better structure would be:
http://site.ext/news/2006/06/06/item123.aspx which is linked at the ‘news-page’ which is available at http://site.ext/news.aspx. You can easily configure this by selecteding the right homeitem and defaultpath in your site.config. Another way is working with proxy-items. You can easily make a proxy item in your site-root which links to the shared(yes we use it for intra- en internet) news-content-folders. I’ll never see a GUID in any URL again(this mistake is made by me to!!!).

Some other stuff: Split your metadata(which is referred by Lookups) and your content tree. For example:
Metdata structure: /sitecore/content/[website]/meta/[category]/[lookupitem]
Website structure: /sitecore/content/[website]/home/……
Your basepath is: /sitecore/content/[website]/
Your startitem will be: /home
When you have to shwo the data of the meta-date for some reason, you can access it easily by using: http://site.ext/meta/[category]/[lookupitem].aspx. So you won’t loose your FriendlyUrls and you don’t have to explain users why they should select X from tree Y.

That’s for me a new way of development. Using our best practices, using shared knowledge. And ofcourse we’ve been upgrading from .NET 1.1 tot 2.0. But that wouldn’t effect us all before my Danish friends finally release 5.3…. 😉