Breaking change in GetChildren()
Let’s say that you need to get hold of all child pages of a certain parent in the EPiServer tree (and by ‘all’ I mean also those not published). With some knowledge of the API, you would quickly assume that the GetChildren method would be the way to go.
The breaking change
Prior to EPiServer CMS 5, the GetChildren method would return all child pages, also including any pages not published yet.
In version 5, this functionality has changed:
“This methods does not filter any pages due to access rights, but it will filter pages not published for the preferred culture”
EPiServer CMS 5 SDK GetChildren method
A workaround
A possible solution (but probably not ‘best practice’) would be to use the parent reference as a Criteria and then find all child pages using the FindPageWithCriteria method.
1: PageReference examples = new PageReference(21);
2:
3: PropertyCriteria parentCr = new PropertyCriteria();
4: parentCr.Type = PropertyDataType.PageReference;
5: parentCr.Value = examples.ID.ToString();
6: parentCr.Name = "PageParentLink";
7: parentCr.Condition =
8: EPiServer.Filters.CompareCondition.Equal;
9:
10: PropertyCriteriaCollection col =
11: new PropertyCriteriaCollection();
12: col.Add(parentCr);
13:
14: PageDataCollection allChildren =
15: DataFactory.Instance.FindPagesWithCriteria(examples, col);
17 February 2009