FindPagesWithCriteria without Criteria

by Dan Matthews 4. March 2008 15:34

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);


Tags:

.NET/C# | EPiServer

Comments

3/5/2008 9:42:37 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)

Ruwen Jin |

8/25/2008 7:53:29 AM #

I solved the issue by recursivly calling GetChildren()

danbad |

9/17/2008 10:59:28 AM #

Thanks for the code... works fine for me...

NET Web Services |

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar