Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using Sitecore.Mvc.Pipelines.Response.RenderRendering;
using Sitecore.Mvc.Presentation;
namespace Sitecore.Foundation.Multisite.Pipelines
public class ResolveRenderingContext : EnterRenderingContext
protected override void EnterContext(Rendering rendering, RenderRenderingArgs args)
//Make your changes to the items that are used to build the context here
if (args.PageContext != null &&
args.PageContext.Item != null &&
var innerQuery = args.Rendering.DataSource.Replace("query:", "");
var datasourceItem= Context.Item.Axes.SelectSingleItem(innerQuery);
//replacing the datasource with Item Id of the queried item
if (datasourceItem != null)
args.Rendering.DataSource = datasourceItem.ID.ToString();
Sitecore.Diagnostics.Log.Error("Resolving Rendering Context >> " + args.Rendering.DataSource + " Not Found", this);
//build the context using the existing functionality
base.EnterContext(rendering, args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.