Skip to content

Instantly share code, notes, and snippets.

@yannisgu
Last active November 30, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yannisgu/d333bae4422957b2501ff7b57894b434 to your computer and use it in GitHub Desktop.
Save yannisgu/d333bae4422957b2501ff7b57894b434 to your computer and use it in GitHub Desktop.
namespace Website.Pipelines
{
public class AddTitle : GetRendererProcessor
{
public override void Process(GetRendererArgs args)
{
....
args.Result = new WrapperViewRenderer(args.Result)
{
Model = model,
Rendering = args.Rendering,
ViewPath = "/Views/WrapperRendering.cshtml"
};
}
}
}
namespace Website.Renderers
{
using Sitecore.Mvc.Presentation;
/// <summary>
/// This WrapperViewRenderer can be used in pipelines which renders markup arround existing renderings (https://ctor.io/wrapping-a-view-rendering-to-automatically-add-additional-markup/).
/// The problem with the approach described in the blog post is, that the cache key will be wrong for personalized elements
/// when they are hidden by personalization.
/// </summary>
/// <seealso cref="Sitecore.Mvc.Presentation.ViewRenderer" />
public class WrapperViewRenderer : ViewRenderer
{
private readonly Renderer innerRenderer;
public WrapperViewRenderer(Renderer innerRenderer)
{
this.innerRenderer = innerRenderer;
}
public override string CacheKey
{
get { return this.innerRenderer.CacheKey; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment