Working with Pages and Fluent API
Hi,
I'm working on developing a custom navigation ad I would like to know how to extract the pages ordered as I see them in the backend.
I use this to retrieve the root node:
App.WorkWith().Pages().Get().Where(p => p.Parent == null && p.Title == "Pages").Single() ;
I'm wondering if there is a better way to extract it as a page Node but the above is working.
And then its children:
App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).
ThatArePublished()
.ThatBelongTo(parent.Id)
.Where(p=>p.ShowInNavigation == true)
.Get().ToList();
What is the right condition for OrderBy() so that I get the order I already see in the admin panel?
Thank you.
Hello,
Why don't you use SiteMapDataSource to populate RadTreeView control? Another option is creating a function that will recursively loop through you pages and its child nodes.
protected virtual void GetNode(PageNode node)
if (node.Nodes.Count > 0)
foreach (van n in node.Nodes)
GetNode(node);
Kind regards,
Ivan Dimitrov
the Telerik team
Hi,
After upgrading to sp1 I was able to sort pages in the backend and I used this order By condition:
.OrderBy(p=> p.Ordinal)
And it is working fine.
I did look through pages and extracted the child nodes, I was wondering if there is a better way to extract the root node.
But I suppose I can leave it as it is, after all it is functioning correctly.
Thank you.
Hello Ancuta,
It would be better if you have some other parameters that you can use, so you will make less calls the the database for getting the nodes. For instance you can also use Take, Skip if the parent has many child nodes.
All the best,
Ivan Dimitrov
the Telerik team