https://github.com/abjerner/limbo.umbraco.multinodetreepicker
Custom multinode treepicker for Umbraco.
https://github.com/abjerner/limbo.umbraco.multinodetreepicker
limbo mntp multi-node-tree-picker skybrud umbraco umbraco-package umbraco-v11 umbracov10 umbravo-v9
Last synced: 4 months ago
JSON representation
Custom multinode treepicker for Umbraco.
- Host: GitHub
- URL: https://github.com/abjerner/limbo.umbraco.multinodetreepicker
- Owner: abjerner
- License: mit
- Created: 2022-09-06T14:15:57.000Z (almost 4 years ago)
- Default Branch: v13/main
- Last Pushed: 2025-05-14T21:36:15.000Z (about 1 year ago)
- Last Synced: 2025-08-21T04:16:36.564Z (10 months ago)
- Topics: limbo, mntp, multi-node-tree-picker, skybrud, umbraco, umbraco-package, umbraco-v11, umbracov10, umbravo-v9
- Language: C#
- Homepage: https://packages.limbo.works/limbo.umbraco.multinodetreepicker/
- Size: 851 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Limbo Multinode Treepicker
[](https://github.com/abjerner/Limbo.Umbraco.MultiNodeTreePicker/blob/v13/main/LICENSE.md)
[](https://www.nuget.org/packages/Limbo.Umbraco.MultiNodeTreePicker)
[](https://www.nuget.org/packages/Limbo.Umbraco.MultiNodeTreePicker)
[](https://marketplace.umbraco.com/package/limbo.umbraco.multinodetreepicker)
[](https://packages.limbo.works/limbo.umbraco.multinodetreepicker/)
**Limbo.Umbraco.MultiNodeTreePicker** adds a special multinode treepicker to the Umbraco backoffice in which developers can select a custom item converter.
The purpose of an item converter is to control the C# type returned by the `.Value()` method or the corresponding property in a ModelsBuilder generated model. This is particular useful in a SPA/Headless Umbraco implementation, where the ModelsBuilder model can then be returned directly via a WebAPI endpoint.
License:
MIT License
Umbraco:
Umbraco 13
Target Framework:
.NET 8
## Installation
The package targets Umbraco 13 and is only available via [**NuGet**][NuGetPackage]. To install the package, you can use either .NET CLI
```
dotnet add package Limbo.Umbraco.MultiNodeTreePicker --version 13.0.4
```
or the NuGet Package Manager:
```
Install-Package Limbo.Umbraco.MultiNodeTreePicker -Version 13.0.4
```
### Umbraco 10, 11 and 12
See the [**`v1.x`**](https://github.com/limbo-works/Limbo.Umbraco.MultiNodeTreePicker/tree/v1/main) branch.
### Umbraco 8 and 9
See our older [**Skybrud.Umbraco.MultiNodeTreePicker**](https://github.com/skybrud/Skybrud.Umbraco.MultiNodeTreePicker) package.
[NuGetPackage]: https://www.nuget.org/packages/Limbo.Umbraco.MultiNodeTreePicker
[GitHubRelease]: https://github.com/abjerner/Limbo.Umbraco.MultiNodeTreePicker/releases
## Examples
At [**@limbo-works**](https://github.com/limbo-works) we typically use Umbraco as a headless CMS, and being able to control the generated models therefore makes a lot of sense. If a given page has some related content, it doesn't make sense for us to return the full model of a related model, so we instead have an item class with the needed properties - this class could be called `TestItem`.
Normally the property with the related content would return the full model for each page, but with the special multinode treepicker from this package, we can implement a custom item converter.
We can do this by implementing the [`IMntpItemConverter`](https://github.com/abjerner/Skybrud.Umbraco.MultiNodeTreePicker/blob/master/src/Skybrud.Umbraco.MultiNodeTreePicker/Converters/IMntpItemConverter.cs) interface, but to get going a bit quicker, the package also contains the abstract [`MntpGenericItemConverter`](https://github.com/abjerner/Skybrud.Umbraco.MultiNodeTreePicker/blob/master/src/Skybrud.Umbraco.MultiNodeTreePicker/Converters/MntpGenericItemConverter.cs) class we can use instead:
```csharp
public class TestMntpItemConverter : MntpGenericItemConverter {
public TestMntpItemConverter() : base("Default item converter", x => new TestItem(x)) { }
}
```
```csharp
public class TestItem {
public Guid Key { get; }
public string Name { get; }
public string Url { get; }
public TestItem(IPublishedContent content) {
Key = content.Key;
Name = content.Name;
Url = content.Url;
}
}
```
The `MntpGenericItemConverter` class requires us to specify a name for the converter, and then a callback function that will be used for converting each `IPublishedContent` to the desired type.

When the data type is configured to use our item converter (see screenshot above), properties of this type will now return `List` instead of `List`.
With this special multinode treepicker, it's the datatype of the individual property, that determines the returned value. Another property could for instance be for selecting contact persons where we'd need a bit more information than what's available from the `TestItem` class, so we can create another item converter:
```csharp
public class TestMntpPersonItemConverter : MntpGenericItemConverter {
public TestMntpPersonItemConverter() : base("Person item converter", x => new TestPersonItem(x)) { }
}
```
```csharp
public class TestPersonItem : TestItem {
public string Phone { get; }
public string Email { get; }
public TestPersonItem(IPublishedContent content) : base(content) {
Phone = content.Value("phone");
Email = content.Value("email");
}
}
```

## Documentation
- [See more at **packages.limbo.works**](https://packages.limbo.works/limbo.umbraco.multinodetreepicker/)
## Inspiration
The item converters in this package was inspired by a similar concept in the [Contentment](https://github.com/leekelleher/umbraco-contentment) package. Thanks for creating and sharing this with us [**@leekelleher**](https://github.com/leekelleher) 👍