Thursday, 18 October 2012

Sitecore Gutter Rendering to Show Language Versions

The current project I'm working on is for a large multi-national company that are using the Sitecore multi-language capabilities to deliver their site in more than 17 regions/languages.

One of the difficulties the content editors have had is identifying from the tree if the item has a version in their regions language or not.  To help with this I suggested a new gutter rendering that would display the flag of the currently selected language for each item that had a version in that language. It turned out to be a very simple process.

To create a new gutter rendering you start by creating a new class that inherits from Sitecore.Shell.Applications.ContentEditor.Gutters.GutterRenderer. (Hint: Sitecore Rocks can help out here!)

Then override the GutterIconDescriptor method to create your own rendering. Just create a new GutterIconDescriptor object and populate the Icon and Tooltip properties. For our purposes I wanted to render the current language flag if the item has a version in that language. So we test for a version in the current language:

 if (item.Versions.Count > 0)  

If we have a version, create the GutterIconDescriptor object and get the flag icon, we can get this from the item.Language.GetIcon(item.Database); method.

So here is the final code listing for the renderer:

 namespace RichardSeal.SitecoreBlog.Exstensions  
     using System;  
     using Sitecore.Data.Items;  
     using Sitecore.Shell.Applications.ContentEditor.Gutters;  
     public class MyLanguageVersion : GutterRenderer  
         protected override GutterIconDescriptor GetIconDescriptor(Item item)  
             if (item.Versions.Count > 0)  
                 var descriptor = new GutterIconDescriptor  
                                  Icon = item.Language.GetIcon(item.Database),  
                                  Tooltip = String.Format("There are {0} versions in your language", item.Versions.Count)  
                 return descriptor;  
             return null;  

The final thing to do is add the gutter menu option in the core database. This is located in /sitecore/content/Applications/Content Editor/Gutters.  Create a new Gutter Renderer item in that folder and add your assembly type.

And thats it!  You will now get the menu item in the right-click of the content editor gutter.

Example screenshots:


Thursday, 5 July 2012

Weird config error in Sitecore

I had a strange error today while testing out my Sitecore build:

Could not find configuration node: settings/setting[@name='LayoutFolder']/@value

As I didn't find anything on Google about this, I had to investigate. Recently we have been following Sitecore best practice of splitting out changes to the Sitecore config to include files. One of these files had been modified locally and also by another dev. Normally SVN would take care of this merge successfully, but in this case the merge had stripped out a comment block but left the closing --> comment tag in, breaking the Xml!

So if you see this error, first place to check is your include files and make sure the Xml is not broken in there.

Next post will be on how we have implemented a Service Stack API utilising Glass ( on our current project!

Tuesday, 7 December 2010

Disable custom errors for a page or group of pages

I had a situation today where I needed a single page on my site to return a proper error code to the client if an exception occurred. As this is a big customer facing site, we had already set up the customErrors tag in the web.config to give the users nice friendly messages.

I was surprised by the lack of information on how to do this when I Googled it. Its probably out there somewhere. But here is how I got around the problem. Simple when you think about it:

To turn off the custom error redirects I put the page in a folder in the site, then all you do is create a web.config file for that folder and set the custom errors mode to off.

Thats all folks...

Its about time....

I've finally got around to posting a blog! After spending ages reading others and getting the benefits of others hard work, it dawned on me that I should start giving back to the community. So here is a blog of my ramblings on Life, Programming, Sitecore, MVC and anything else I think of.

My only hope is that someone else can benefit this time round... Enjoy!