Content Picker and Dynamic Roots

I’m working to replicate some old “Multi Node Tree Picker” behavior.

I want to create a Content Picker that renders without a tree and shows a “simple” list of options like this:

However, my tree structure looks like this (I wan to show the options in the red boxes)

Ideally I would like to do something like:

  • Find “Hitta till oss”
  • Query for descendants (at any level) of type “Office Department”

I managed to implement a custom IDynamicRootQueryStep that returns the Guid for all the 8 nodes that I need in the picker, but the UI renders like this:

And when I include the Offices in the query, it seems like it’s picking the first Office and render it’s children

Is the “dynamic root” by design only able to list children of a node or I’m I missing something?

Could it be that you need to return a UDI for dyamicpath over GUID.. eg umb://document/{guid}

I think there is a utlity method in lit/c# in core to get that from a guid,

But reminded me: re flattened.. even allowed templates don’t use the flattened view they used to.. instead making the editor go searching across folders for a choice of two allowed templates. (where once two clicks selected my template, now it takes 3+ (and more if I have to expand lots of nesting to find my template)

@mistyn8,

The IDynamicRootQueryStep-interface wants me to return a collection of Guids.

Or in what context are you referring to?

Good find, I think that this is a problem, it would have been much better if there was a way to show a flat list of pickable items in some contexts.

Apologies, I was guessing on the dynamicpath… as Guids don’t indicate document/media/member…
The old mntp covered all the types.. now I think the v17 approach is content picker/media picker/member picker separate pickers.

Yes, the “Content Picker” can be configured to pick Documents, Media or Members which are all considered “Content” in the Umbraco-world :slight_smile:

Could it be that providing all the parent nodes in IDynamicRootQueryStep then looks in the child folders of those nodes? So in your example you’d pass back Göteborg, Stockholm, and Jönköping?

Seems worth a try.

@jonathoncove3 Yes, when I do that only the children of the first item returned is used.

From the Umbraco Core source:

if (result && result.length > 0) {
    this._rootUnique = result[0];
}

Seems like this on the HQ-radar

@markusjoha I had a bit of a look..

The backend interface (IDynamicRootQueryStep) uses an ICollection<Guid> return type because query steps can conceptually resolve multiple branch paths or unions (for example, finding matching categories or multi-site fallback roots).

And for your use case I think the dynamic root part should be returning your 3 guids..
`Goetborg, Stockholm, Jonkoping"

However, the UI tree-picker implementation then expects a single starting node.. it can’t display multiple trees… Hence why it only shows your first tree from Offices when you include those.

(built in core are singular though.. nearest or furthest… prob due to that)

So think you are railing against a UI contraint.

You can however, create a custom property editor that also implements dynamic root setting and then either try and reuse multiple .. or just a your own ui at this point .

{
  alias: "startNode",
  label: "Start node",
  description: "Limit picker to a specific node and its descendants",
  propertyEditorUiAlias: "Umb.PropertyEditorUi.ContentPicker.Source",
},

gets you a dynamicPath config option on the propertyEditor

As far as I know, the Content Picker accepts one root path, like the ‘start node’. It’s not meant for aggregating multiple children of multiple root nodes. It’s just a filter to scope the ‘root node’. So if multiple nodes match the dynamic root, it will just take the first.

Contentment has very nice pickers where you can use queries to get what you want to do. Umbraco has a concept of Property Editor data sources, but that is pretty limited, so I’d go for contentment.

Contentment is a great shout.. though probably would still benefit from a tree picker for the use case here.. as we have duplicated department names in the offices..
A flat list would have to concatenate {office}{department} ?

Though that was actually the original request :slight_smile:

Yep, we’re using Contentment as a work around right now but would love to have a native way.

Fair, this is just a sample-app - the original use case does not have duplicates :slight_smile:

It’s fair to say that contentment is not ‘native’, but on the other hand, it exists for a long time and has a proven track record. And Lee is now even an Umbraco employee :wink: So I wouldn’t worry too much about using it; we’re using it in almost all our projects.

I know :slight_smile: We use Contentment all the time :slight_smile: But this feels like something that could be improved in core.

The closest is the is the Property Editor data sources that I mentioned before. That’s mainly used for Umbraco compose and has no real implementations yet, but it is exactly what Contentment more or less does: feed a property editor based on a data source.

I have created a plugin for this: