From 29e45534c51f61439606eeaa9188f97fd49bb80b Mon Sep 17 00:00:00 2001 From: Marc Goodson Date: Sat, 25 Jun 2016 10:54:10 +0100 Subject: [PATCH] Add an overload to GetDictionaryValue to provide a fallback - U4-8657 --- src/Umbraco.Web/UmbracoHelper.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index 6d5e33b239..098e56f0dd 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -375,7 +375,21 @@ namespace Umbraco.Web { return CultureDictionary[key]; } - + /// + /// Returns the dictionary value for the key specified, and if empty returns the specified default fall back value + /// + /// key of dictionary item + /// fall back text if dictionary item is empty - Name altText to match Umbraco.Field + /// + public string GetDictionaryValue(string key, string altText) + { + var dictionaryValue = GetDictionaryValue(key); + if (String.IsNullOrWhiteSpace(dictionaryValue)) + { + dictionaryValue = altText; + } + return dictionaryValue; + } /// /// Returns the ICultureDictionary for access to dictionary items ///