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
category.StringCondition
is not correct for comparing Categories. I use criteria.Condition = CompareCondition.Equal
My code, which works fine, looks like this:
public static PropertyCriteria GetCategoryCriteria(ArrayList selections)
{
PropertyCriteria criteria = null;
if (selections.Count > 0)
{
criteria = new PropertyCriteria();
criteria.Condition = CompareCondition.Equal;
criteria.Type = PropertyDataType.Category;
criteria.Value = String.Join(",", (String[]) selections.ToArray(typeof(String)));
criteria.Name = "PageCategory";
criteria.Required = true;
}
return criteria;
}
Hope that helps.
Jon
PropertyCriteria category = new PropertyCriteria(); category.Name = "PageCategory"; category.Type = PropertyDataType.Category; category.StringCondition = EPiServer.Filters.StringCompareMethod.Identical; category.Value = "903"; //comma-separated list of ids or names PropertyCriteriaCollection col = new PropertyCriteriaCollection(); col.Add(category); PageDataCollection pdcNews = new PageDataCollection(); pdcNews = Global.EPDataFactory.FindPagesWithCriteria(EPiServer.Global.EPConfig.StartPage, col);
/Jonas