0 votes

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.

 

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.

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:

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).

 

Screenshots

NuGet install instructions for Umbraco 9+

dotnet add package Wholething.FallbackTextProperty

Package owner

Wholething

Wholething

Wholething has 71 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
Version 10.0.x (untested)
Version 9.1.x (untested)
Version 9.0.x (untested)
Version 8.18.x (untested)
Version 8.17.x (untested)
Version 8.16.x (untested)
Version 8.15.x (untested)
Version 8.14.x (untested)
Version 8.13.x (untested)
Version 8.12.x (untested)
Version 8.11.x (untested)
Version 8.10.x (untested)
Version 8.9.x (untested)
Version 8.8.x (untested)
Version 8.7.x (untested)
Version 8.6.x (untested)
Version 8.5.x (untested)
Version 8.4.x (untested)
Version 8.3.x (untested)
Version 8.2.x (untested)
Version 8.1.x (untested)
Version 8.0.x (untested)
Version 7.15.x (untested)
Version 7.14.x (untested)
Version 7.13.x (untested)
Version 7.12.x (untested)
Version 7.11.x (untested)
Version 7.10.x (untested)
Version 7.9.x (untested)
Version 7.8.x (untested)
Version 7.7.x (untested)
Version 7.6.x (untested)
Version 7.5.x (untested)
Version 7.4.x (untested)
Version 7.3.x (untested)
Version 7.2.x (untested)
Version 7.1.x (untested)
Version 7.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Wholething
  • Contributors: Ault Nathanielsz , Harry Gordon , Dean Leigh
  • Created: 11/10/2021
  • Current version 0.2.26
  • License MIT
  • Downloads on Our: 0
  • Downloads on NuGet: 431
  • Total downloads : 431