Thursday, March 2, 2017

Dictionary Items

1. No editable in Experience Mode
2. Custom method to show hover state:

public static string GhsTranslate(string key)
        {
            string translatedKey = Sitecore.Globalization.Translate.TextByDomain("Dictionaries", key);          

            if (Sitecore.Context.PageMode.IsExperienceEditorEditing)
            {
                string test = string.Format("<span class=\"dictionary-key\" title=\"{0}\">*{1}*</span>", HttpUtility.HtmlEncode(key), translatedKey);
                return test;
            }

            return translatedKey;
        }


In the view:

<h2>@Html.Raw(Helpers.GhsTranslate("lp-recent-claims"))</h2>

When dictionary item's value refuses to show up delete the dictionary.dat file in the webroot in Website/temp, restart IIS and republish the entire parent folder with dictionaries.



No comments:

Post a Comment