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)
{
base.OnLoad(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")
filteredCollection.Add(page);
}
yourPageList.DataSource = filteredCollection;
}
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.
Thanks!
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();
}
}
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.
Currently, we have a section of our site that is structured as follows:
Archives (PageList)
2013(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:
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!