Query PageData by title
Native API
PageData has a NavigationNode property that holds the reference to the page metadata that is located in the PageNode. To query a PageData by its title, use the following code sample:
C#
using System.Linq;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.Pages.Model;
namespace SitefinityWebApp
{
public class QueryPages_PageData_NativeAPI
{
public static PageData FindPageByTitleNativeAPI(string title)
{
PageManager pageManager = PageManager.GetManager();
PageData page = pageManager.GetPageDataList().Where(pData => pData.NavigationNode.Title == title).FirstOrDefault();
return page;
}
}
}
Fluent API
To find a specific PageData by its title, you use the plural page facade to ensure that the PageNode with the specified title of the PageData exists. Then, you use the Get method of the plural page facade to get thePageNode. To get the PageData, you use the Page property in the following way:
C#
using System.Linq;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Pages.Model;
namespace SitefinityWebApp
{
public class QueryPages_FindPageByTitle_FluentAPI
{
public PageData FindPageByTitleFluentAPI(string pageTitle)
{
PageData pageData = null;
var count = 0;
App.WorkWith().Pages().Where(pN => (pN.Page != null && pN.Page.Title == pageTitle)).Count(out count);
if (count != 0)
{
pageData = App.WorkWith().Pages().Where(pN => (pN.Page != null && pN.Page.Title == pageTitle)).Get().First().Page;
}
return pageData;
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.