UmbracoKeyValuePropertyEditor 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UmbracoKeyValuePropertyEditor --version 1.0.0                
NuGet\Install-Package UmbracoKeyValuePropertyEditor -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UmbracoKeyValuePropertyEditor" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UmbracoKeyValuePropertyEditor --version 1.0.0                
#r "nuget: UmbracoKeyValuePropertyEditor, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UmbracoKeyValuePropertyEditor as a Cake Addin
#addin nuget:?package=UmbracoKeyValuePropertyEditor&version=1.0.0

// Install UmbracoKeyValuePropertyEditor as a Cake Tool
#tool nuget:?package=UmbracoKeyValuePropertyEditor&version=1.0.0                

Umbraco.KeyValuePropertyEditor · GitHub license NuGet version (Umbraco.KeyValuePropertyEditor) Twitter

Umbraco.KeyValuePropertyEditor property editor for Umbraco

This installs a custom property editor that can be used to configure external data to Umbraco nodes

After installing this, you can add inherit from KeyValueUmbracoPropertyEditorController to implement an api endpoint that can server as a data source, for example: to create the following API endpoint /umbraco/backoffice/Sample/LanguageDemoApi here is the sample code needed.

using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Extensions;
using Umbraco.KeyValuePropertyEditor;

namespace ExternalApiPickerDemo.Core.Demo
{
	[PluginController("Sample")]
	public class LanguageDemoApiController : KeyValueUmbracoPropertyEditorController
	{
		private readonly UmbracoHelper _umbracoHelper;
		private readonly ILocalizationService _localizationService;

		public LanguageDemoApiController(UmbracoHelper umbracoHelper, ILocalizationService localizationService)
		{
			_umbracoHelper = umbracoHelper;
			_localizationService = localizationService;
		}
			
		public override IOrderedEnumerable<KeyValuePair<string, string>> GetKeyValueList(int nodeId, string propertyAlias, int uniqueFilter = 0, int allowNull = 0)
		{
			try
			{
				string[] usedUpLanguageCodes = Array.Empty<string>();
				try {
					var parent = _umbracoHelper.Content(nodeId).Parent;
					usedUpLanguageCodes = (parent == null ? _umbracoHelper.Content(nodeId).Children.Where(c => c.Id != nodeId).Select(c => c.Value<string>(propertyAlias)?.ToLowerInvariant()) : parent.Children.Where(c => c.Id != nodeId).Select(c => c.Value<string>(propertyAlias)?.ToLowerInvariant()).Union(_umbracoHelper.Content(nodeId).Children.Where(c => c.Id != nodeId).Select(c => c.Value<string>(propertyAlias)?.ToLowerInvariant()))).ToArray();
				} catch { uniqueFilter = 0; }
				LanguageDTO[] languageList = null;
				if (uniqueFilter == 1)
				{
					languageList = (new LanguageApiWrapper(_localizationService)).AllLanguages.Where(c => !usedUpLanguageCodes.Contains(c.ISOCode.ToLowerInvariant())).ToArray();
				}
				else
				{
					languageList = (new LanguageApiWrapper(_localizationService)).AllLanguages.ToArray();
				}
				if (allowNull == 1)
				{
					languageList = languageList.Prepend(new LanguageDTO { ISOCode = "", EnglishName = "NONE" }).ToArray();
				}
				return languageList.ToDictionary(c => c.ISOCode.ToLowerInvariant(), c => c.EnglishName).OrderBy(v => v.Value);
			}
			catch
			{
				return null;
			}
		}
	}
}
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Services;

namespace ExternalApiPickerDemo.Core.Demo
{
	public class LanguageApiWrapper
	{
		private readonly ILocalizationService _localizationService;

		public LanguageApiWrapper(ILocalizationService localizationService)
		{
			_localizationService = localizationService;
		}

		public IEnumerable<LanguageDTO> AllLanguages => _localizationService.GetAllLanguages().Select(l => new LanguageDTO() { ISOCode = l.IsoCode, EnglishName = l.CultureName });
	}
}
namespace ExternalApiPickerDemo.Core.Demo
{
	public class LanguageDTO
	{
		public string ISOCode { get; set; }
		public string EnglishName { get; set; }
	}
}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on UmbracoKeyValuePropertyEditor:

Package Downloads
UmbracoMongoContactNumber

This package gives Umbraco editors to have the pleasure of using a property editor that is specific to phone numbers with their respective country phone codes etc, the database storing country phone code data is in MongoDB.

UmbracoLanguagePicker

...

UmbracoCountryPicker

...

UmbracoSingleKeyValuePicker

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
14.3.0 263 9/24/2024
14.2.0 86 9/24/2024
14.1.0 200 9/10/2024
14.0.0 130 6/5/2024
13.0.2 271 4/16/2024
13.0.1 115 4/16/2024
13.0.0 202 12/16/2023
12.0.0 327 7/1/2023
5.0.0 1,893 9/24/2022
4.0.0 869 9/24/2022
3.2.0 450 9/21/2022
3.1.1 422 9/21/2022
3.1.0 426 9/21/2022
3.0.0 417 9/21/2022
2.0.0 441 9/21/2022
1.0.0 468 7/16/2022