This Umbraco package provides two custom text property editors, "Textstring with Fallback" and "Textarea with Fallback", 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.
There are a number of known issues so please check the issue tracker when in doubt.
Blocks and nested content only have limited support since we can't retrieve an element's parent/owner in the value converter. The following references do work:
root
and url
functionsThe use-case for this package is simple: 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.
This property editor is a collaboration between Harry Gordon and Wholething (Dean Leigh and Ault Nathanielsz).
You can find the package on NuGet: https://www.nuget.org/packages/Wholething.FallbackTextProperty/
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:
The fallback template supports the following node references:
{{1069:propertyAlias}}
{{25eb6a38-50e0-4c1b-95d8-1526d54b06e5:propertyAlias}}
{{parent:propertyAlias}}
{{root:propertyAlias}}
{{ancestor(blogPost):propertyAlias}}
{{url(/global-settings/):propertyAlias}}
As of version 1.3 we now log any template rendering errors to the Umbraco log.
The implementation is fairly straight-forward and involves the following:
There are a few notable limitations:
The package is built in Azure DevOps but in the event that you need build it locally you can use the following command (replacing local-package-path
and version
):
dotnet pack Wholething.FallbackTextProperty\Wholething.FallbackTextProperty.csproj --output {local-package-path} /p:Configuration=Debug /p:PackageVersion={version}-local --include-symbols