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

Forums / Developing with Sitefinity / Querying live pages using FluentAPI returns blank page names

Querying live pages using FluentAPI returns blank page names

2 posts, 0 answered
  1. David
    David avatar
    99 posts
    Registered:
    06 Sep 2012
    01 Apr 2015
    Link to this post

    Problem:

    When I use the FluentAPI to query pages, only the pages that were created as part of the Sitefinity installation have a value for the name property. 

    Steps to Duplicate:
    1. Log into SItefinity back office and create and publish at least one front-end page.

    2. Create a page named DemoLivePages.aspx in Visual Studio

    3. Add a GridView to DemoLivePages.aspx

    4. Bind the GridView using the following code:

    public IQueryable<PageNode> GetLivePagesFluentAPI()
    {
        IQueryable<PageNode> pageNodes = App.WorkWith().Pages().Where(pN => (pN.Page != null && pN.Page.Status == ContentLifecycleStatus.Live)).Get();
        return pageNodes;
    }

    5. Run the page with the Grid and none of the pages created in Step 1 have a value for the name property. Only the pages that were created during the Sitefinity installation return a name.

    Below are some additional things I tried (did not work). Note that in the following I am attempting to get the page title instead of name. This is because there was not a Name property for any of the following approaches.

    1. Visual Studio gave me a warning that node.Page is depcreciated. I tried it anyway.

    IQueryable<PageNode> pageNodes = GetLivePagesFluentAPI();
     
    foreach (PageNode node in pageNodes)
    {
        Response.Write(node.Page.Title + "<hr />");
    }
     

     2. The decreciation message suggested I use GetPageData() and NavigationNode.Title. Tried that below but it did not work either.

    IQueryable<PageNode> pageNodes = GetLivePagesFluentAPI();
     
    foreach (PageNode node in pageNodes)
    {
        Response.Write(node.GetPageData().NavigationNode.Title + "<br />");
    }

     

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    02 Dec 2016
    06 Apr 2015
    Link to this post
    Hi David,

    Can you please try to get the titles of the pages using the following sample code:

    protected void Page_Load(object sender, EventArgs e)
            {
                var pages = GetLivePagesFluentAPI();
     
                foreach (var page in pages)
                {
                    string name = page.Title;
                }
            }
     
            public IQueryable<PageNode> GetLivePagesFluentAPI()
            {
                IQueryable<PageNode> pageNodes = App.WorkWith()
                    .Pages()
                    .Where(pN => (pN.Page != null && pN.Page.Status == ContentLifecycleStatus.Live && pN.IsBackend == false))
                    .Get();
                 
                return pageNodes;
            }


    Regards,
    Sabrie Nedzhip
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered