Easy access of datasource and rendering parameters from your controllers using Glass Mapper for Sitecore without GlassController

In a recent project I was working on, I found myself needing a way to be able to get at the rendering parameters and / or datasource of the rendering when using controller renderings. Below is a quick snippet to show one approach of how you can approach this problem. Continue reading


Glass Mapper V4 – Redis Cache Provider

Following on from my post on the new caching functionality in Glass Mapper V4, I thought I would do something that I have been really dying to try, which is to look at using Redis to cache the models generated out of Glass. This from an architectural standpoint for me is just plain amazing :D. In this post, I will show you how you can set up a redis based cache provider for Glass Mapper V4. This post will assume you know how to set up caching on your models (shown in my previous post).

** Note – this is a proof of concept, it has not yet been tested in production, all the regular no warranty disclaimers apply.

Continue reading

Glass Mapper V4 – Configuration Maps

Something I had a look at quite a while back was the fluent configuration api in Glass. Unlike many developers, I am absolutely 100% fine with adding spaces to field names and don’t like using attribute based configuration in Glass. I talked about this in some detail a while ago in Introducing Glass Maps. I have since been through several iterations and finally settled on one that I like and therefore contributed to Glass itself. In essence, it is simply a neat way of bundling your fluent mapping into discrete units, which allows you to keep the mapping isolated from your POCO’s.

I understand this is not to every developers taste, but if you like to see clean .net objects, this my be the mapping configuration type for you.

Continue reading

Glass Mapper V4 – Caching

Following on in my series looking at the new features in Glass Mapper v4.

One of my favourite features of Glass V4 is the new Caching feature. This at at in its simplest form allows you to cache the object that Glass produces, much like we do in regular .net development for slower running processes. In this post I will describe some more about caching, how to set it up and what it does.

Continue reading

Life Through A Lens – Using your own IoC container with Glass Mapper

This should be a nice quick post, but when I look back, it’s something I have done on every project I have used Glass Mapper on.

Glass’ out of the box Castle Windsor implementation tends to create it’s own IWindsorContainer during Sitecore’s initialise pipeline (formerly done using WebActivator). This is great if you want to get up and running quickly, but in my case – especially with the new Delegate mapping function available, I often find that I would rather have a more global container than this, since – for example, some of the delegate mapping does use dependencies from my codebase.

In this post I will quickly describe how to use an external Castle Windsor container with Glass Mapper. If you want to find out more on using other IoC containers including Autofac, StructureMap or Unity as the container for Glass, please take a look at Glass Mapper On Agnostic IoC

Continue reading

Life Through a Lens – Glass Tip – Casting Items to Objects in Glass Mapper

This actually should be a fairly quick post, but one that I have seen a few times over now. It is simply a quick answer to the following question – ‘how can I get a POCO (object) given the Sitecore item?’. Before you question too much, I will also explain why the answer is (mostly) not GlassCast(this Item item). This question crops up reasonably regularly, especially given the number of pipelines / commands where we are presented with the item as an argument. There are actually a few considerations when looking at this question and some better and worse ways of achieving this. This post covers many of the common mistakes I have seen when using Glass Mapper in my implementations.

Continue reading