More in this section

Forums / Developing with Sitefinity / Getting published pages from API

Getting published pages from API

2 posts, 0 answered
  1. Suzanne
    Suzanne avatar
    43 posts
    Registered:
    12 Jul 2012
    09 Sep 2011
    Link to this post
    I'm running into an issue getting published pages programmatically.  Currently, I'm using 

     IEnumerable<PageNode> pageNodes = parentNode.Nodes.Where(m => m.ShowInNavigation && (m.ApprovalWorkflowState == "Published" || m.ApprovalWorkflowState == "")).OrderBy(m => m.Ordinal);

    which returns published pages but if a page was published but is now in Draft mode currently the page is not returned but it needs to be returned. Basically, I need to be able to get all "live" pages.
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    13 Sep 2011
    Link to this post
    Hello Suzanne,

    I have prepared a code sample for you which should get all pages you want:

    public IQueryable<PageNode> GetLivePages()
               {
                   IQueryable<PageNode> pageNodes = App.WorkWith()
                                                       .Pages()
                                                       .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
                                                       .Where(pN => pN.ApprovalWorkflowState == "Published")
                                                       .ThatArePublished()
                                                       .Where(pN => (pN.Page.Status == ContentLifecycleStatus.Temp && pN.Page.Version > 0&& pN.Page.Visible == true)|| pN.Page.Status == ContentLifecycleStatus.Live )
                                                       .OrderBy(pN => pN.Ordinal)
                                                       .Get();
                   return pageNodes;
               }

    Regards,
    Victor Velev
    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
2 posts, 0 answered