Statically add a Rendering to a layout

Recently I stumbled across this excellent note from Nathanael Mann – Did you really mean .Controller() in Sitecore MVC? – it’s worth a read.

The short form – you’ll want to use:

@Html.Sitecore().Rendering("[GUID of the Rendering]", new { Cacheable=true, Cache_VaryByData=true })

… so you don’t skip caching.

 

Advertisements
Statically add a Rendering to a layout

Programmatically reset a a Sitecore Item’s presentation details

Just a quick post – should you need to reset an item back to using the controls defined on its template’s standard values, you can easily achieve this through code:

using (new Sitecore.SecurityModel.SecurityDisabler())
{
using (new Sitecore.Data.Items.EditContext(item))
{
item.Fields["__renderings"].Reset();
}
}

I’ve tried it, and it worked.

Programmatically reset a a Sitecore Item’s presentation details