Alias: Umbraco.MultiNodeTreePicker
Returns: IEnumerable<IPublishedContent>
The Content Picker enables you to select the type of content tree to display and which specific part of it should be rendered. It also allows you to choose a dynamic root node for the content based on the current document using the Content Picker.
The Content Picker was formerly known as the Multinode Treepicker in version 13 and below.
The renaming is purely a client-side UI change, meaning the property editor still uses the Umbraco.MultiNodeTreePicker
schema alias.
The change was made as the word Content in the backoffice acts as an umbrella term covering the terms Document, Media, and Member.
Are you looking for the original Content Picker?
The Content Picker from version 13 and below has been renamed to Document Picker.
Set the type of node, the root node of the tree, or query for the root node.
For querying content, you can specify a dynamic root:
When you specify the dynamic root, you can navigate the tree relative to a node.
First, you have to specify an origin, from where the query will start.
You have the following options:
Root - The root is the first level item of the subtree of the current node.
Parent - The parent is the nearest ancestor of the current node.
Current - The current node. Be aware a picker that uses the current node, cannot pick anything when the current node is created, because it does not have any children.
Site - The nearest ancestor of the current node that has a domain assigned.
Specific node - A specific node that you have to choose in the tree
Often an origin is a good dynamic root. It is also possible to execute multiple steps from the origin to navigate the tree to find another root.
You have the following options:
Nearest Ancestor or Self - Finds the nearest ancestor or the item itself, that fits with one of the configured document types.
Furthest Ancestor or Self - Finds the furthest ancestor or the item itself, that fits with one of the configured document types.
Nearest Descendant or Self - Finds the nearest descendant or the item itself, that fits with one of the configured document types.
Furthest Descendant or Self - Finds the furthest descendant or the item itself, that fits with one of the configured document types.
Custom - Execute a custom query step by specifying the name. This requires custom code to add the new query step.
Each query step takes the output from the last step (or the origin) as input.
Custom query steps can be used to solve some specific use cases.
To add a custom query step, you need to append it to the existing query steps. This can be done from a composer:
The implementation of a query step takes in a collection of origins and information about the query step. The collection is taken from where the name specified in the UI can be found.
The code needed to create a custom query step is shown in the following example.
You can inject dependencies into the constructor. Some interesting dependencies could be custom repositories or the IVariationContextAccessor
, if you want to use the current culture.
The ExecuteAsync
method gets a collection of content keys from the last executed query step or the origin. It has to return a new collection of content keys.
Allow or disallow tree nodes with a certain content type alias.
Enter typeAlias,altTypeAlias
to allow selection of nodes with those aliases only. Enter !typeAlias,altTypeAlias
to allow selection of nodes without those aliases.
Set a limit on the number of items allowed to be selected.
Consider the following tree structure where Document Type alias is presented in square brackets.
Codegarden
2023 [year]
Talks [talks]
...
Umbraco anno MMXXIII [talk]
Stages [stages]
Social Space [stage]
No 10 [stage]
No 16 [stage]
The Theatre [stage]
2022 [year]
Talks [talks]
...
Stages [stages]
Main Stage [stage]
The Barn [stage]
The Theatre [stage]
Consider configuring a picker on the talk Document Type to select a stage of the talk. Here, you want to display only the stages for the actual year. To do this, you need to set the parent as origin.
For instance, if you are on the Umbraco anno MMXXIII
node, the collection of content keys passed into the first query step will only contain the Talks
content node.
First, query for the nearest ancestors of the type year
. This will return 2023
.
Next, query for the nearest descendants of type stages
.
When opening the picker on the Umbraco anno MMXXIII
node, it will now show the children of the node on path Codegarden => 2023 => Stages
.
See the example below to see how a value can be added or changed programmatically. To update a value of a property editor you need the Content Service.
The example below demonstrates how to add values programmatically using a Razor view. However, this is used for illustrative purposes only and is not the recommended method for production environments.
Although the use of a GUID is preferable, you can also use the numeric ID to get the page:
If Modelsbuilder is enabled you can get the alias of the desired property without using a magic string: