Created
June 29, 2017 19:22
-
-
Save 5up3rman/5d1bafecabb68dbeb928461abb651e07 to your computer and use it in GitHub Desktop.
AddWrapper Example
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
using Sitecore; | |
using Sitecore.Mvc.ExperienceEditor.Presentation; | |
using Sitecore.Mvc.Pipelines.Response.RenderRendering; | |
using Sitecore.Mvc.Presentation; | |
namespace EditorEnhancementToolkit.Foundation.ContentEditor.Pipelines.RenderRenderer | |
{ | |
public class AddWrapper : Sitecore.Mvc.ExperienceEditor.Pipelines.Response.RenderRendering.AddWrapper | |
{ | |
public override void Process(RenderRenderingArgs args) | |
{ | |
if (Context.Site == null || !Context.PageMode.IsExperienceEditorEditing || !args.Rendering.RenderingType.Equals("Layout")) | |
return; | |
var marker = GetMarker(args.Rendering); | |
if (marker == null) | |
{ | |
base.Process(args); | |
return; | |
} | |
var index = args.Disposables.FindIndex(x => x.GetType() == typeof (Wrapper)); | |
if (index < 0) | |
index = 0; | |
args.Disposables.Insert(index, new Wrapper(args.Writer, marker)); | |
} | |
protected IMarker GetMarker(Rendering rendering) | |
{ | |
return new RenderingMarker(RenderingContext.Current, rendering.RenderingItem.DisplayName); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment