AI OnAI Off
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