An EPiServer frustration for me is not being able to grab a 'deep' tree as a PageDataCollection. Sometimes I want to be able to iterate through a collection of all descendants of a page.

Ideally I'd want to do a GetChildren with a 'deep' boolean parameter or something, but there isn't one. Trying to use FindPagesWithCriteria is frustrating as if you enter no Criteria then it returns nothing.

For now, I've just hacked it with the following code. It works, but I hate it. If you have a better solution please let me know. And yes, I know that I could iterate through GetChildren but that would be lots and lots of separate API calls and I really don't want to take that hit. I want a one-time API hit.

   1: PropertyCriteriaCollection oColl = new PropertyCriteriaCollection();
   2: PropertyCriteria oCrit = new PropertyCriteria();
   3:  
   4: oCrit.Condition = EPiServer.Filters.CompareCondition.GreaterThan;
   5: oCrit.Name = "PageStartPublish";
   6: oCrit.Value = DateTime.Parse("1/1/1900").ToString();
   7: oCrit.Type = PropertyDataType.Date;
   8:  
   9: oColl.Add(oCrit);
  10:  
  11: PageDataCollection oChildPages = DataFactory.Instance.FindPagesWithCriteria(oPageData.PageLink, oColl);



Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, March 04, 2008 3:34 PM | in .NET/C# EPiServer

Comments

Gravatar
# re: FindPagesWithCriteria without Criteria
Posted by Ruwen Jin
on 3/5/2008 9:42 AM
There is a page tree control you could use. There is pagetreeloader in EPiServer CMS 4. Here is code for EPiServer CMS 5:
EPiServer.Web.WebControls.PageTreeData ptd = new EPiServer.Web.WebControls.PageTreeData();

ptd.PageLink = page.PageLink;
ptd.ShowRootPage = false;
ptd.NumberOfLevels = -1;
ptd.ExpandAll = true;
ptd.EnableVisibleInMenu = false;

foreach (PageData pd in ptd)
Gravatar
# re: FindPagesWithCriteria without Criteria
Posted by danbad
on 8/25/2008 8:53 AM
I solved the issue by recursivly calling GetChildren()
Gravatar
# re: FindPagesWithCriteria without Criteria
on 9/17/2008 11:59 AM
Thanks for the code... works fine for me...

Post Comment

Title *
Name *
Email
Url
Comment *  


Please add 5 and 6 and type the answer here: