1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Working with Pages and Fluent API

Working with Pages and Fluent API

4 posts, 0 answered
  1. Ancuta Me
    Ancuta Me avatar
    43 posts
    Registered:
    26 Apr 2010
    13 May 2011
    Link to this post
    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.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    17 May 2011
    Link to this post
    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
  3. Ancuta Me
    Ancuta Me avatar
    43 posts
    Registered:
    26 Apr 2010
    19 May 2011
    Link to this post
    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.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 May 2011
    Link to this post
    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
4 posts, 0 answered