As discussed in modelsbuilder/ModelsBuilder.Original#206 and modelsbuilder/ModelsBuilder.Original#235, the current options to get fallback values are quite minimal or very verbose. Some things can be fixed within Models Builder (e.g. generating additional extension methods accepting fallback options), customizing the model classes or even replacing the IPublishedValueFallback.
One thing that might be a good addition is adding Fallback.ToDefaultLanguage, so you can get a fallback value from the default language without configuring the fallback chain on the languages themselfs.
The default PublishedValueFallback implementation already depends on ILocalizationService, so getting the default langauge can be done using _localizationService.GetDefaultLanguageIsoCode():
|
public PublishedValueFallback(ServiceContext serviceContext, IVariationContextAccessor variationContextAccessor) |
|
{ |
|
_localizationService = serviceContext.LocalizationService; |
|
_variationContextAccessor = variationContextAccessor; |
|
} |
Looking at the code and comments in this class, it already requires some attention. Most of the logic can be moved into a base class, so replacing it with a custom implementation (e.g. using a custom language fallback chain or recurse ancestors & languages) can be written a lot easier!
As discussed in modelsbuilder/ModelsBuilder.Original#206 and modelsbuilder/ModelsBuilder.Original#235, the current options to get fallback values are quite minimal or very verbose. Some things can be fixed within Models Builder (e.g. generating additional extension methods accepting fallback options), customizing the model classes or even replacing the
IPublishedValueFallback.One thing that might be a good addition is adding
Fallback.ToDefaultLanguage, so you can get a fallback value from the default language without configuring the fallback chain on the languages themselfs.The default
PublishedValueFallbackimplementation already depends onILocalizationService, so getting the default langauge can be done using_localizationService.GetDefaultLanguageIsoCode():Umbraco-CMS/src/Umbraco.Web/Models/PublishedContent/PublishedValueFallback.cs
Lines 21 to 25 in 51d7ce0
Looking at the code and comments in this class, it already requires some attention. Most of the logic can be moved into a base class, so replacing it with a custom implementation (e.g. using a custom language fallback chain or recurse ancestors & languages) can be written a lot easier!