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.
This Article Contains
New to Sitefinity?