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
Oct 04, 2006 14:28
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
Oct 09, 2006 18:31
* 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.