Get pages with category

Vote:
 
I can't get this to work, shouldn't it return all pages with category 903? 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
#12798
Mar 25, 2008 18:35
Vote:
 
Hi, I think maybe your 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
#14916
Mar 25, 2008 18:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.