Value Converter

The `UmbNavValueConverter` handles converting raw JSON property data into `IEnumerable<UmbNavItem>`. Extend it for custom conversion logic.

Overview

The value converter is automatically invoked when you call:

Model.Value<IEnumerable<UmbNavItem>>("propertyAlias")

It handles:

  1. Deserializing JSON from the database

  2. Calling the Menu Builder Service to process items

  3. Converting configuration to build options

Basic Extension

using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Community.UmbNav.Core.Abstractions;
using Umbraco.Community.UmbNav.Core.Converters;

public class CustomUmbNavValueConverter : UmbNavValueConverter
{
    public CustomUmbNavValueConverter(
        ILogger<UmbNavValueConverter> logger,
        IUmbNavMenuBuilderService umbNavMenuBuilderService)
        : base(logger, umbNavMenuBuilderService)
    {
    }
}

Registering Your Converter

Value converters are registered automatically by Umbraco. To override, use a composer:

Override Points

ConvertIntermediateToObject

The main conversion method for standard property access:

ConvertIntermediateToDeliveryApiObject

Conversion for the Delivery API:

Complete Example: Caching Converter

Complete Example: Analytics Tracking

Complete Example: Multi-Language Enrichment

Delivery API Considerations

When customizing for the Delivery API:

Build Options from Configuration

The base converter creates build options from the Data Type configuration:

You can override this by creating custom build options in your converter.

Testing

Last updated

Was this helpful?