private Page GetPageByUrlIdentifier(Site site, Page page, string identifier) { var lastPage = page.LastVersion(site).AsActual(); if (lastPage.VirtualPath.EqualsOrNullEmpty(identifier, StringComparison.OrdinalIgnoreCase)) { return(lastPage); } foreach (var item in PageProvider.ChildPages(page)) { var found = GetPageByUrlIdentifier(site, item, identifier); if (found != null) { return(found); } } return(null); }
public void Test_AddSubPage_ChildPages() { var parentPage = new Page(sampleSite, "Parent"); var subPage = new Page(parentPage, "Sub"); pageProvider.Add(parentPage); pageProvider.Add(subPage); var allPages = pageProvider.All(sampleSite); Assert.AreEqual(2, allPages.Count()); var childPages = pageProvider.ChildPages(parentPage); Assert.AreEqual(1, childPages.Count()); Assert.AreEqual(subPage.GetParent().AbsoluteName, childPages.First().GetParent().AbsoluteName); pageProvider.Remove(subPage); pageProvider.Remove(parentPage); }