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;
}
}
-
1Does this answer your question? This "Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering" is not found in Sitecore.Mvc.Analytics10.0.3– Sumit HelaiyaCommented Aug 11, 2023 at 10:49
Add a comment
|
2 Answers
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
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