Is this really the version you are looking for? Kentico 8.1 documentation is no longer updated. Use the switch in the header to choose your Kentico version.

Working with pages in the API

The Kentico API allows you to fully manage pages in custom code.

Use the following classes from the CMS.DocumentEngine namespace:

  • TreeNode - represents pages. Encapsulates data from the CMS_Tree and CMS_Document tables, and the coupled data tables of individual page types.
  • TreeProvider - provides management functionality for latest published tree nodes (pages).
  • DocumentHelper - provides static methods for managing the latest edited versions of pages.
  • TreeHelper - provides static methods for loading tree nodes (pages). Allows you to work with pages without creating instances of the TreeProvider class.

Use the API Examples application to see the use of these classes.

Retrieving latest edited pages

  • Retrieving the latest edited version of all pages:

    var pages = DocumentHelper.GetDocuments();
  • Retrieving the latest edited version of pages of a specific class:

    var pages = DocumentHelper.GetDocuments("CMS.Product");
  • Example that retrieves all CMS.Product pages under the /Products/ path that have Apple at the beginning of their DocumentName:

    var pages = DocumentHelper.GetDocuments("CMS.Product").Path("/Products/", PathTypeEnum.Children).Where("DocumentName", QueryOperator.Like, "Apple%");

Retrieving latest published pages

  • Retrieving the latest published version of pages:

    TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
    var pages = tree.SelectNodes();
  • Retrieving the latest published version of pages of a specific class:

    TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
    var pages = tree.SelectNodes("CMS.Product");
  • Example that retrieves all CMS.Product pages under the /Products/ path that have Apple at the beginning of their DocumentName:

    TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
    var pages = tree.SelectNodes("CMS.Product").Path("/Products/", PathTypeEnum.Children).Where("DocumentName", QueryOperator.Like, "Apple%");
On this page

In this section