General query syntax
The Sitecore query syntax leverages the concept of a context item and uses the following symbols to reference related items:
|
Symbol |
Description |
|---|---|
|
/ |
The root of the content tree or a parent-child relationship. |
|
text |
Match by item name. |
|
# |
Escape text containing dashes (-) . For example: #meta-data#. It can also be used to escape special words, for example: #and#, #or#. |
|
* |
Wildcard, match items of any name. |
|
.. |
The parent of the context item. |
|
[ ] |
Search criteria related to fields and XML element attributes. |
|
@ |
A field defined in the item’s base template |
|
@@ |
An XML element attribute, all Sitecore items are treated as “item” elements, which contain the following attributes:
|
Combining these symbols references specific items or groups of items. For example:
|
Sitecore query string |
Result set |
|---|---|
|
|
The root of the content tree. |
|
|
The Sitecore home item. |
|
|
Immediate subitems under the home item that contain a Title field that starts with P. |
|
Sitecore query string |
Result set |
|---|---|
|
|
All hidden subitems underneath the context item. |
|
|
A Source field that selects all subitems under the Color item that have the Show check box selected. |
|
|
Subitems under the context item based on the Folder template. |
Where possible, avoid using the / symbol, because it can make the query more complex, resulting in performance issues. For instance, query:$site is preferable to query:/$site .
Variables
You can include the following variables in a query:
-
$compatibleThemes- path to all themes. -
$theme- currently used theme. -
$pageDesigns- root of page designs (sitecore/content/<site collection>/<site>/Presentation/Page Designs). -
$partialDesigns- root of partial designs (sitecore/content/<site collection>/<site>/Presentation/Partial Designs). -
$currenttemplate- name of the current template. -
$tenant- path to the current site collection. -
$site- path to the current site. -
$home- path to the current site start item (by default: /sitecore/content/<site collection>/<site>/Home). -
$linkableHomes- paths to home items from linkable sites. -
$templates- path to the current site templates (/sitecore/templates/Project/Site Collection). -
$siteMedia- paths to media folders specified inAdditional Childrenfield on virtual media folder item. -
$sharedSites- for multiroot fields, resolves shared site for the current site collection. -
$rvSystemTemplates- list of templates defined in a configuration. These templates are used to feed theAllowedInTemplatesfield for rendering variants. -
$xaRichTextProfile- theXA.Foundation.Editing.DefaultRichTextProfilesetting value. -
$sitelang- the default language for the context site, which is set on the site definition item. -
$lang- the context language. -
$vf- the virtual folder for the context site.