Wholething.FallbackTextProperty 0.2.26

Install-Package Wholething.FallbackTextProperty -Version 0.2.26
dotnet add package Wholething.FallbackTextProperty --version 0.2.26
<PackageReference Include="Wholething.FallbackTextProperty" Version="0.2.26" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Wholething.FallbackTextProperty --version 0.2.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Wholething.FallbackTextProperty, 0.2.26"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Wholething.FallbackTextProperty as a Cake Addin
#addin nuget:?package=Wholething.FallbackTextProperty&version=0.2.26

// Install Wholething.FallbackTextProperty as a Cake Tool
#tool nuget:?package=Wholething.FallbackTextProperty&version=0.2.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Wholething Fallback Text Property

This Umbraco package provides two custom text property editors that allow developers to enter "fallback value", rendered from a Mustache template. The fallback can be built from other node properties and properties of other specific nodes in the content tree.

If you like this property editor you may also like Wholething.FallbackImagePickerProperty.

Use-case

Editors often want the option to override images/values but it is unclear what the default value is. We feel it's a significant improvement in experience for editors to be able to see the default value before deciding to override it.

Team

This property editor is a collaboration between Harry Gordon and Wholething (Dean Leigh and Ault Nathanielsz).

Installation

You can find the package on NuGet: https://www.nuget.org/packages/Wholething.FallbackTextProperty/

Configuration and editor experience

When you configure a "Textstring with Fallback" or "Textarea with Fallback" property you must configure a Mustache template to generate the fallback value.

fallback-text-1

In the example we use the following template: {{1104:heroHeader}} - {{pageTitle}} - Bar. In this case pageTitle refers to the nodes own property, 1104:heroHeader refers to the site home node's property heroHeader and the rest is literal. The result can be seen below:

fallback-text-2

Implementation

The implementation is fairly straight-forward and involves the following:

  • The property editor builds a dictionary of node properties and their values and does the same for any other nodes mentioned in the template.
  • The property editor renders the fallback template but does not store that in the field value (to avoid "caching" depedent values).
  • There is a value converter that returns either the entered value or renders the fallback value.

Limitations

There are a few notable limitations:

  • The fallback template can only handle simple properties. For example referring to other fallback properties in a fallback template wouldn't work.
  • The fallback template rendering does not currently use live values, just whatever is in the model when the editor is loaded.
  • Referring to other nodes in the template by node ID is not ideal, it's a suitable proof of concept but we'd like to look at other ways (for example, by name, doc type or URL).

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.26 103 9/9/2021
0.1.23 66 3/24/2021
0.1.21 93 3/24/2021
0.1.11 87 2/3/2021
0.1.6 75 1/27/2021

0.2 - Package now supports Umbraco 8 and 9 via multi-targeting