Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
We implement IContentApiModelFilter in a more simple fasion, allowing us to perform better SOC in the end, see https://docs.developers.optimizely.com/content-management-system/v1.5.0-content-delivery-api/docs/how-to-customize-data-returned-to-clients
This will in it's most simple form look something like this
public class PageBaseFilter : IContentApiModelFilter
{
public void Filter(ContentApiModel contentApiModel, ConverterContext converterContext)
{
if (contentApiModel.ContentLink != null)
{
contentApiModel.Properties.Add("Id", contentApiModel.ContentLink.GuidValue.ToString());
}
// more more more
}
}
Hi all,
Currently I am looking into customizing the response of the content delivery api by adding new properties.
For now I was able to achieve something of that sort by overriding the ContentConvertingService class.
I would like to know if there is a better approach to add custom properties to the content delivery api.
public class CustomContentConvertingService: ContentConvertingService { public CustomContentConvertingService(IContentConverterResolver contentConverterResolver, IEnumerable<IContentFilter> contentFilters, IEnumerable<IContentApiModelFilter> contentApiModelFilters) : base(contentConverterResolver, contentFilters, contentApiModelFilters) { } public override ContentApiModel ConvertToContentApiModel(IContent content, ConverterContext converterContext) { var data = base.ConvertToContentApiModel(content, converterContext); data.Properties.Add("NewProperty", "NewPropertyData"); return data; } }