Bind Pages Facade to a Menu
Is there a sample somewhere on binding pages to a RadMenu as per the sitemap in the backend?
This is what I have
var pages = App.WorkWith()
.Pages()
.ThatArePublished()
.Where(x => x.ShowInNavigation ==
true
&&
x.IsBackend ==
false
&&
x.Ordinal > 0)
.Get();
menu.DataSource = pages.OrderBy(x => x.Ordinal);
menu.DataBind();
Hello Steve,
You are right, the list you get back is flattened. The fluent API is used to work with data objects but it doesn't guarantee preserving the hierarchy of pages - that is a job for the sitemap. Is there any particular reason you want to use the fluent API in this case? Here's how I bound a RadMenu to the sitemap:
var ds = SiteMap.RootNode.ChildNodes;
this
.menu.DataFieldParentID =
"Key"
;
this
.menu.DataSource = ds;
this
.menu.DataBind();
ShowInNavigation is the problem I'm having, the SiteMap doesn't seem to respect it...
It appears this has not been implemented yet. When working with plain LINQ queries like the code below an error pops up as soon as I add the "where o.ShowInNavigation" statement.
var mgr = PageManager.GetManager();
var nodes = mgr.GetPageNodes();
var q = (from o
in
nodes
where o.ShowInNavigation
select o);
Hi Rein,
Hi there is a bug in the link parser. To workaround it you should use :
o.ShowInNavigation == true
instead only o.ShowInNavigation.
var mgr = PageManager.GetManager();
var nodes = mgr.GetPageNodes();
var q = (from o in nodes
where o.ShowInNavigation == true
select o).ToList();