Created
July 13, 2017 17:07
-
-
Save 5up3rman/41e382cd1b96461c9a544f72dd31797a to your computer and use it in GitHub Desktop.
Inject Assets Page Extender
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 System.Web.UI; | |
using EditorEnhancementToolkit.Foundation.ContentEditor.Pipelines.RenderPageAssets; | |
using Sitecore; | |
using Sitecore.Layouts; | |
using Sitecore.Layouts.PageExtenders; | |
using Sitecore.Pipelines; | |
namespace EditorEnhancementToolkit.Foundation.ContentEditor.PageExtenders | |
{ | |
public class InjectAssetsPageExtender : PageExtender | |
{ | |
public override void Insert() | |
{ | |
var assetArgs = new RenderPageAssetsArgs(); | |
CorePipeline.Run("renderPageAssets", assetArgs); | |
AddControlToPage(assetArgs.Control); | |
} | |
private static void AddControlToPage(Control control) | |
{ | |
if (control == null) | |
return; | |
Context.Page.AddRendering(new RenderingReference(control) | |
{ | |
Placeholder = "webedit", | |
AddToFormIfUnused = true | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment