0
using Sitecore.Data.Items;
using Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering;
using Sitecore.Pipelines;
using Sitecore.Pipelines.ResolveRenderingDatasource;

public class CustomMVCResolveRenderingDataSource : CustomizeRenderingProcessor
{
    public override void Process(CustomizeRenderingArgs args)
    {
        var rendering = args.Rendering;
        //Get the Site Item
        var contextSiteItem = GetSiteItem(Context.Item);

        if (!string.IsNullOrEmpty(rendering.DataSource) && contextSiteItem != null)
        {
            if (rendering.DataSource.Contains("$SiteName"))
            {
                rendering.DataSource = rendering.DataSource.Replace("$SiteName", contextSiteItem.Name);
                Item sourceItem = Context.Database.GetItem(rendering.DataSource);
                if (sourceItem != null)
                {
                    rendering.DataSource = sourceItem.ID.ToString();
                }
            }
        }
        //Initialize the resolved DataSource to ResolveRenderingDatasourceArgs
        var renderingDSArgs = new ResolveRenderingDatasourceArgs(rendering.DataSource);
        CorePipeline.Run("resolveRenderingDatasource", renderingDSArgs);
        rendering.DataSource = renderingDSArgs.Datasource;
    }
}
1

2 Answers 2

1

In Sitecore 10.3 Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering logic is moved to Sitecore.Personalization.Mvc dll

Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering use this

1
  • 1
    Thanks for sharing it just works fine now... Commented Aug 11, 2023 at 11:38
3

In Sitecore 10.3 Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering namespace no longer exists.

All the logic is moved to Sitecore.Personalization.Mvc dll, including:

  • Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.CustomizeRenderingArgs
  • Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.CustomizeRenderingProcessor
  • Sitecore.Personalization.Mvc.Pipelines.Response.CustomizeRendering.Personalize

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.