Working with Pages and Fluent API

Posted by Community Admin on 04-Aug-2018 14:58

Working with Pages and Fluent API

All Replies

Posted by Community Admin on 13-May-2011 00:00

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.

Posted by Community Admin on 17-May-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 19-May-2011 00:00

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.

Posted by Community Admin on 19-May-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed