![]() |
VOOZH | about |
dotnet add package UmbracoKeyValuePropertyEditor --version 14.3.0
NuGet\Install-Package UmbracoKeyValuePropertyEditor -Version 14.3.0
<PackageReference Include="UmbracoKeyValuePropertyEditor" Version="14.3.0" />
<PackageVersion Include="UmbracoKeyValuePropertyEditor" Version="14.3.0" />Directory.Packages.props
<PackageReference Include="UmbracoKeyValuePropertyEditor" />Project file
paket add UmbracoKeyValuePropertyEditor --version 14.3.0
#r "nuget: UmbracoKeyValuePropertyEditor, 14.3.0"
#:package UmbracoKeyValuePropertyEditor@14.3.0
#addin nuget:?package=UmbracoKeyValuePropertyEditor&version=14.3.0Install as a Cake Addin
#tool nuget:?package=UmbracoKeyValuePropertyEditor&version=14.3.0Install as a Cake Tool
UmbracoKeyValuePropertyEditor 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.Models.PublishedContent;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Extensions;
using UmbracoKeyValuePropertyEditor;
namespace ExternalApiPickerDemo.Core.Demo
{
[PluginController("UmbracoLanguagePicker")]
public sealed class LanguageApiController : KeyValueUmbracoPropertyEditorController
{
private readonly UmbracoHelper _umbracoHelper;
private readonly ILocalizationService _localizationService;
public LanguageApiController(UmbracoHelper umbracoHelper, ILocalizationService localizationService)
{
_umbracoHelper = umbracoHelper;
_localizationService = localizationService;
}
public override IOrderedEnumerable<KeyValuePair<string, string>> GetKeyValueList(string nodeIdOrGuid, string propertyAlias, bool uniqueFilter, bool allowNull)
{
try
{
string[] usedUpLanguageCodes = Array.Empty<string>();
try
{
// Current node block
IPublishedContent currentNode = null;
if (int.TryParse(nodeIdOrGuid, out int nodeId) && nodeId > 0)
{
currentNode = _umbracoHelper.Content(nodeId);
}
else if (Guid.TryParse(nodeIdOrGuid, out Guid Key))
{
currentNode = _umbracoHelper.Content(Key);
}
// Parent node block
IPublishedContent parentNode = null;
if (int.TryParse(parentNodeIdOrGuid, out int parentNodeId) && parentNodeId > 0)
{
parentNode = _umbracoHelper.Content(parentNodeId);
}
else if (Guid.TryParse(parentNodeIdOrGuid, out Guid Key))
{
parentNode = _umbracoHelper.Content(Key);
}
usedUpLanguageCodes = GetValuesOfChildrensProperty(parentNode, propertyAlias, currentNode?.Id).ToArray();
}
catch { uniqueFilter = false; }
LanguageDTO[] languageList = null;
if (uniqueFilter)
{
languageList = (new LanguageApiWrapper(_localizationService)).AllLanguages.Where(c => !usedUpLanguageCodes.Contains(c.ISOCode.ToLowerInvariant())).ToArray();
}
else
{
languageList = (new LanguageApiWrapper(_localizationService)).AllLanguages.ToArray();
}
if (allowNull)
{
languageList = languageList.Prepend(new LanguageDTO { ISOCode = "", EnglishName = "" }).ToArray();
}
return languageList.ToDictionary(c => c.ISOCode.ToLowerInvariant(), c => "").OrderBy(v => v.Key);
}
catch
{
return null;
}
}
private IEnumerable<string> GetValuesOfChildrensProperty(IPublishedContent node, string propertyAlias, int nodeId)
{
var nodes = node == null ? _umbracoHelper.ContentAtRoot() : node.Children;
return nodes.Where(c => c.Id != nodeId).Select(c => c.Value<string>(propertyAlias)?.ToLowerInvariant());
}
}
}
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 14.3.0 | 493 | 9/24/2024 |
| 14.2.0 | 251 | 9/24/2024 |
| 14.1.0 | 397 | 9/10/2024 |
| 14.0.0 | 279 | 6/5/2024 |
| 13.0.2 | 426 | 4/16/2024 |
| 13.0.1 | 243 | 4/16/2024 |
| 13.0.0 | 352 | 12/16/2023 |
| 12.0.0 | 518 | 7/1/2023 |
| 5.0.0 | 2,273 | 9/24/2022 |
| 4.0.0 | 1,058 | 9/24/2022 |
| 3.2.0 | 622 | 9/21/2022 |
| 3.1.1 | 586 | 9/21/2022 |
| 3.1.0 | 582 | 9/21/2022 |
| 3.0.0 | 570 | 9/21/2022 |
| 2.0.0 | 580 | 9/21/2022 |
| 1.0.0 | 639 | 7/16/2022 |