Last active
November 30, 2016 10:41
-
-
Save yannisgu/d333bae4422957b2501ff7b57894b434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
}; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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