SaaS CMS has officially launched! Learn more now.

Need to Pull Data from Multiple PageLists


Currently, we have a section of our site that is structured as follows:

Archives (PageList)


News Story (News Article)

News Story (News Article)

2012 (PageList)

News Story (News Article)


The issue is I need to pull the news stories despite the year and display them on our home page. When I set "Archives" as the data source, it only pulls "2013" and "2012". Is there a way to skip over the secondary PageLists so I can display the news stories.

I've tried to filter using the following:

private void HomeNewsPageList_Filter(object sender, FilterEventArgs e)
            var pages = e.Pages;
            for (int i = pages.Count - 1; i > -1; i--)
                if (pages[i].PageName as string == PageBase.Translate("/news/archivesheading") || pages[i].PageTypeName as string != "News Article" || pages[i].PageName.Length == 4)


This seems to be a start in the right direction to exclude the secondary PageList, but I cannot display the respective children. Any suggestions?


Thanks in advance!





Apr 08, 2013 10:17

You coud try to set the DataSource on your list in pageload instead of directly in the control. You need to fetch descendants, not only children.

This should work:

protected override void OnLoad(EventArgs e)

List<PageReference> pageRefs = DataFactory.Instance.GetDescendents(LinkToArchivePage);

PageDataCollection filteredCollection = new PageDataCollection();

foreach (PageReference pageReference in pageRefs)
PageData page = DataFactory.Instance.GetPage(pageReference);
if (page.PageTypeName == "News Article")


yourPageList.DataSource = filteredCollection;




Apr 09, 2013 11:33

I didn't see this sooner. Thank you for the prompt reply. I'm now subscribed to email notifications on this thread so I won't miss anything again. The code builds, but now I realize I haven't handled filtering the results by the currently selected language. Any thoughts? After researching, it seems maybe I should have gone down the "FindPagesWithCriteria" approach, but I'm wondering if there's a way to modify what you've provided without having to start over. I tried the code below and it almost works, but now is pulling in the page lists as well (2013,2012 from the first post) well.



protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { this.LanguageString = (System.Globalization.CultureInfo.CurrentCulture).ToString(); HomePageNewsList.PageLinkProperty = PageLinkProperty; if (MaxCountProperty != null && CurrentPage[MaxCountProperty] != null) { HomePageNewsList.MaxCount = (int)CurrentPage[MaxCountProperty]; } // Hide the whole control if the list is empty //this.Visible = HomePageNewsList.DataCount > 0; PageReference NewsPullPage = CurrentPage.Property["MainListRoot"].Value as PageReference; IList<PageReference> pageRefs = DataFactory.Instance.GetDescendents(NewsPullPage); PageDataCollection filteredCollection = new PageDataCollection(); foreach (PageReference pageReference in pageRefs) { PageData page = DataFactory.Instance.GetPage(pageReference); if (page.PageTypeName == "News Article" && page.LanguageBranch == LanguageString && page.PageName.Length != 4) filteredCollection.Add(page); } HomePageNewsList.DataSource = filteredCollection; HomePageNewsList.DataBind(); } }


Edited, Apr 17, 2013 4:17

I think it is this line that make the 2012, 2013 pages appear in your list:

HomePageNewsList.PageLinkProperty = PageLinkProperty;

You kind of set the datasource twice I think. I do not think it is possible for the 2012 and 2013 pages to be added with the filter (the if-sentence) in place.


Try to remove the codeline mentioned and I think it should work. 

Apr 17, 2013 7:49

Yep, of course that was the problem. Thank you so much!!

Apr 17, 2013 20:54
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.