child pages

Vote:
 

Hi,

 

I need to display content in boxes from children pages. The pages I want to collect data from are children of child pages... how would I access pages farther down in the node tree than immediate children?

 

cheers!

#31056
Jul 01, 2009 12:38
Vote:
 

I would use FindPagesWithCriteria. Something like this:

var criterias = new PropertyCriteriaCollection();
 
            var pubCriteria = new PropertyCriteria();
            pubCriteria.Condition = CompareCondition.Equal;
            pubCriteria.Name = "PagePendingPublish";
            pubCriteria.Type = PropertyDataType.Boolean;
            pubCriteria.Value = false.ToString();
            criterias.Add(pubCriteria);

PageDataCollection matches = Global.EPDataFactory.FindPagesWithCriteria(CurrentPage.PageLink, criterias);

Hope it helps.

Frederik 

 

#31057
Jul 01, 2009 12:59
Vote:
 

this helps a great deal... I have a place to start for sure.

 

would I add the boolean property "PagePendingPublish" to each child page I wish to publish?

 

Cheers,

Chris

#31060
Jul 01, 2009 13:27
Vote:
 
Or if you are using CMS 5 you can use

PageDataCollection pageColl = DataFactory.Instance.GetDescendents(yourStartingPage.PageLink);

 Then you can filter the result afterwards if you want to.

 

Andreas

#31061
Jul 01, 2009 13:28
Vote:
 

 

If you are using CMS 5 and above, you can use nested foreach loops to get down to the child of child pages. First loop go over the children, nested one go over the children of children.

 

here is a sample code

 

  //get the page reference to start page
         PageReference productStartPage =   CurrentPage.Property["ProductStartPage"].Value as PageReference;

            //get the children
            PageDataCollection products = GetChildren(productStartPage);
   
        //loop through children   
            foreach (PageData product in products)
            {
       
              //get page reference to that chidren page   
              PageReference currentProduct = product.PageLink
       
        //get child pages for the current children page or grandchildren of start page
               PageDataCollection childproducts = GetChildren(currentProduct);

            //loop through them
                        foreach (PageData child in childproducts)
                        {
                            //find the relvant product
                            if (child.PageName == ProductDropDownList.SelectedItem.Value)
                            {
                    //do somthing
                }
            }

       }

#31379
Edited, Jul 24, 2009 1:17