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
Hi,
I think you should create an custom control for contentarea and inject your custom content filter:
[TemplateDescriptor(TagString = "FilterByMarket")]
public class MyContentAreaControl : PropertyContentAreaControl, IRenderTemplate<ContentArea>
{
private ContentControlResolver _contentControlResolver;
new public ContentControlResolver ContentControlResolver
{
get
{
var contentControlResolver = _contentControlResolver ?? (_contentControlResolver = ServiceLocator.Current.GetInstance<ContentControlResolver>());
if (contentControlResolver.ContentFilter == null)
{
contentControlResolver.ContentFilter = new FilterContentForMarket();
}
return contentControlResolver;
}
set
{
_contentControlResolver = value;
}
}
}
public class FilterContentForMarket : IContentFilter
{
public bool ShouldFilter(IContent content)
{
//TODO: Get current market and check whethers the current content is in current market or not.
}
}
Some helpful links you may need:
// Ha Bui
Hi,
Is there a way to filter content area items, in this case products (EntryContentBase which has implementation of markets), so that we're only render items that are in the current market? I guess this question goes for other content types and custom filtering as well.
From what I know there is no convenient way to bind your own content area items to a PropertyContentAreaControl.
And when we're at it, there should be an implementation of IContentFilter that filters content on the current market. Right now we have to do it by calling the extension method IsAvailableInCurrentMarket() on every content item, which works but doesn't follow the same convention as in CMS.