Querying live pages using FluentAPI returns blank page names
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 />"
);
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;