Kentico CMS 7.0 Developer's Guide

Appendix A - Path expressions

Appendix A - Path expressions

Previous topic Next topic Mail us feedback on this topic!  

Appendix A - Path expressions

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Path expressions allow you to select a set of documents from the content tree of Kentico CMS websites. The expressions are based on the alias path values of documents. You can use either the exact paths of individual documents or expressions containing special characters, which specify multiple documents or relative paths.

 

For example, path expressions are commonly used in the Path property of web parts and controls that provide navigation elements or display document data.

 

Using wildcard characters % and _

 

You can use % as a wildcard character for any number of characters, which allows you to select all documents under the specified site section.

 

Examples:

 

/ - only the root document

/% - all documents

 

/Products - only the Products document

/Products/% - all child documents under the Products document

 

You can also use _ as a wildcard representing single character.

 

Examples:

 

/Product_ - selects documents /ProductA, /Product1, etc.

 

Leaving the Path value empty

 

In many cases, you can leave the Path value empty.

 

For navigation controls/web parts (such as CMSMenu/Drop‑down menu), an empty value sets the path to all documents: /%

 

Listing controls/web parts with document data sources (such as CMSRepeater/Repeater) evaluate empty path values dynamically based on the document type of the current document:

 

If the type matches the value of the web part or control's ClassNames (Document types) property, the empty path automatically selects the current document.

If the document type does not match, the path is set to all child documents: <current alias path>/%

 

Getting parts of the path

 

You can use special expressions to extract parts of the current document's path.

 

{0} - the alias of the document on the first level of the current path

{1} - the document alias of the current path's second level

...

 

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

 

{0} = Company

{1} = Careers

{3} = Development

 

Path examples:

 

/{0}/{1}/% - all documents under the second level of the current path

/{0}/{1}/Details - document Details under the second level of the current path

 

 

InfoBox_Note

 

Note

 

If you attempt to extract a level that does not exist in the current document'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.

 

Using relative paths

 

You can use relative paths expressions to specify sub-documents or parent documents:

 

Examples:

 

. - current path

.. - parent document of the current path

./Product - document Product under the current path

../Product - document Product under the parent document of the current path

./% - all documents under the current path

../% - all documents under the parent document of the current path