Writing page path expressions

Path expressions allow you to select a set of pages from the content tree of Kentico websites. The expressions are based on the alias path values of pages. You can use two types of path values:

  • Exact paths of individual pages
  • Expressions containing special characters that specify multiple pages or relative paths

You need to use path expressions in the Path property of web parts or controls that load data from pages (page data sources, page listings with built-in data sources, navigation components).

Using wildcard characters (% and _)

The % wildcard represents any number of characters.Add the wildcard to the end of the path to select all pages under the specified section of the site.

Examples:

  • / - only the root page
  • /% - all pages
  • /Products - only the Products page
  • /Products/% - all child pages under the Products page

The _ wildcard represents a single character. For example:

  • /Product_ - selects pages /ProductA, /Product1, Product2 etc.

Escaping wildcards in paths

If you need to use the wildcards as standard characters inside path expressions, enclose the character inside brackets ([ ]). For example:

  • /Special[_]Offers - selects the Special_Offers page

Using relative paths

You can use relative paths expressions to select child pages or parent pages.

Examples:

  • . - the current page’s path
  • .. - the path of the current page’s parent
  • ./Product - page Product under the current path
  • ../Product - page Product under the parent page of the current path
  • ./% - all pages under the current path (or selection of the current page, see Leaving the Path value empty below)
  • ../% - all pages under the parent page of the current path

Leaving the Path value empty

If you leave the path value empty, the behavior depends on the type of the component and other variables.

For navigation components (such as the CSS list menu web part), an empty value always sets the path to all pages (equivalent of /%).

Standard page data sources

General web parts and controls with page data sources perform one of the following actions if you leave the Path property empty:

  • Selection of the current page - the component loads and displays only the current page using the Selected item transformation (if specified).
  • Loading of child pages - equivalent of <current alias path>/%. All filtering options specified for the data source still apply.

The behavior depends on the following conditions:

* Whether the listing component’s Page types (ClassNames) property includes the current page’s page type. Note: An empty value includes all page types.
** If the current page type has the Behaves as Page (menu item) type flag enabled (Page types -> Edit the page type -> General).

Page type match (*)

Behaves as Page (menu item) type flag (**)

Empty path behavior

Selection of the current page

Loading of child pages

Loading of child pages

The data source does not load any data at all

For standard page data sources, the ./% path expression works exactly the same way as an empty path value.

Getting parts of the current path

You can use special expressions to extract parts of the current page’s path.

  • {0} - the alias of the page on the first level of the current path
  • {1} - the page alias of the current path’s second level

For example, if the page path is: /Company/Careers/USA-Branch/Development/QA-Engineer

  • {0} = Company
  • {1} = Careers
  • {3} = Development

Path examples:

  • /{0}/{1}/% - all pages under the second level of the current path
  • /{0}/{1}/Details - page Details on the third level of the current path

Note: If you attempt to extract a level that does not exist in the current page’s path:

  • The expression returns an empty value.
  • If there is a slash (/) after the expression, the system removes it when resolving the overall path.