For developers: Query pages
This topic explains how to query instances of page nodes. The examples below show you how to query the following:
To find a specific page you can use the Native API or the Fluent API.
To find a specific page using the Native API, you use the PageManager class and LINQ queries. For more information, see Find pages using Native API.
To find a specific page using the Fluent API, you use the page facade. For more information, see Find pages using Fluent API.
Find pages using Native API
Find page node by ID
To find a specific page node by ID, you use the GetPageNodes method:
To find the page node, you use the GetPageNodes method and filter based on the Id property. If the page node does not exist, the method returns null.
To find the page node, you can also use the GetPageNode method: PageNode node = pageManager.GetPageNode(pageNodeId);
The GetPageNode method throws an exception of type ItemNotFoundException, if there is no page node with the specified Id.
Find page data by ID
To find a specific page data by ID, you use the GetPageDataList method:
To find the page data, you use the GetPageDataList method and filter based on the Id property. If the page data does not exist, the method returns null.
To find the page data, you can also use the GetPageData method:
PageData page = pageManager.GetPageData(pageDataId);
The GetPageData method throws an exception of type ItemNotFoundException, if there is no page data with the specified Id.
PageData now has a NavigationNodeproperty that holds the reference to the page metadata (located in the PageNode). Previously, the PageNode had a Page property (of typePageData that is now obsolete). The main impact of this change is on Multilingual Split pages. You now get the PagaData of the PageNode in a different way:
Find page data by URL of node
To find a specific page data by the URL of the node, first, you use the GetPageNodes method. Then you filter based on the UrlName property:
Get pages by template
To get pages by a specified template you must first get an instance of the LibrariesManager object. Then, you must get an instance of the specified template. To get the pages using this template, call the Pages extension method of the PageTemplate instance. This extension method is located in the Telerik.Sitefinity.Modules.Pages namespace. Here is a code example:
Get all live pages
To get all live pages, first, you use the GetPageDataList method. Then, you filter based on the Status property:
Find pages using Fluent API
To find a page using the Fluent API, you must use the page facade.
To initialize the page facade, you use App.WorkWith().Page() for the singular page facade or App.WorkWith().Pages() for the plural page facade.
Find page node by ID
To find a specific page node by ID, first, you use the plural page facade to assure that the page node exists. Then, you use the Get method of the singular facade to get the page node:
If you do not assure that the page node exists, the
Get method throws an exception of type
ItemNotFoundException, if there is no page node with the specified
Id.
Find page data by node ID
To find a specific page data by its node ID, first, you use the plural page facade to assure that the page node exists. Then, you use the Get method of the singular facade to get the page node. To get the PageData, you use the Page property:
If you do not assure that the page data exists, the Get method throws an exception of type ItemNotFoundException, if there is no page data with the specified Id.
Find page data by title
To find a specific page data by its title, first, you use the plural page facade to assure that the page node with the specified title of the PageData exists. Then, you use the Get method of the plural page facade to get the page node. To get the PageData, you use the Page property:
Find page data by URL of the node
To find a specific page data by the URL of the node, first, you use the plural page facade to assure that the page node with the specified UrlName exists. Then, you use the Get method of the plural page facade to get the page node. To get the PageData, you use the Page property:
Get pages by template
To get the pages that use a specified template you must first get the plural facade for the pages. Then filter the pages by the ID of the specified template and their status. Call the Get method of the facade to get the query.
Get all live pages
To get all live pages, first, you use the plural facade to get all page nodes. Then, you filter based on the Status property of the PageData object:
Get all translations of a page
Native API
To get all translations of a page, you use the
GetPageDataList method. Then, you filter based on the
Culture property, the
LocalizationStrategy,
NodeType and
RootNodeId. As a result, you get all pages for a specific language:
Fluent API
To get all live pages, first, you use the plural facade to get all page nodes. Then, you filter based on the
NodeType property and the
PageData object: