public void Can_find_page_at_level() { var data = new Website(XElement.Parse( @"<website title=""My Website""> <page name="""" title="""" template=""template.htm""/> <page name=""page-1"" title=""Page 1"" template=""template.htm""/> <page name=""page-2"" title=""Page 2"" template=""template.htm""> <page name=""page-3"" title=""Page 3"" template=""template.htm""/> <page name=""page-4"" title=""Page 4"" template=""template.htm""> <page name=""page-4-1"" title=""Page 4-1"" template=""template.htm""/> <page name=""page-4-2"" title=""Page 4-2"" template=""template.htm""/> </page> <page name=""page-5"" title=""Page 5"" template=""template.htm""/> </page> </website>")); Assert.Same(data.Pages[2].Pages[1], data.FindCurrentPageAtLevel(2, data.Pages[2].Pages[1].Pages[1])); }
public override IEnumerable <XObject> Render(string data) { if (data.StartsWith("level-")) { var level = int.Parse(data.Substring("level-".Length)); var p = Website.FindCurrentPageAtLevel(level, Page); if (p.Any()) // has child pages? { yield return(new XElement("ul", new XAttribute("id", "cms-navigation-level-" + level), BuildMenu(p, Page, level) )); } } else { yield return(new XElement("ul", new XAttribute("id", "cms-navigation"), BuildMenu(Website, Page, 0) )); } }