Have you ever seen an odd issue where your field title is different from the one you defined on your template even if you didn’t set any Display Name value? Well, here I will explain how you can come across with this issue and how you can resolve it.
Take a look at the sample item that comes with a new Sitecore instance: /sitecore/templates/Sample/Sample Item
And now let’s see the __Standard Values item, which basically has a Title (with a token $name) and Text.
Now, I want to reproduce the “issue” I’m talking about; Let’s create a dictionary entry (/sitecore/templates/System/Dictionary/Dictionary entry), under the system dictionary, /sitecore/system/Dictionary.
If you take a look closely, you will notice that the key has the same value as one of our fields in the Sample item template.
Mysteriously, the title of our field has changed!!
The title of the Text field changed to “This is the text”. My first impression when this thing happened to me is that the Display name has been set, but if we look at that field, we don’t have any value in there.
When Sitecore loads the template content editor, it calls to the EditorFormatter which is the responsible for rendering the form. It includes buttons, sections and fields.
When it render each field, there is method that renders the field title:
title = (field.TemplateField.IgnoreDictionaryTranslations ? itemField.Name : Translate.Text(itemField.Name));
In this case, it’s triggering the Translate.Text(“Text”) which results “This is the text”.
If we don’t want to use any dictionary entry than can replace the field title, we can enable the Ignore Dictionary Translations inside the Data section of each field.
Then you will see the correct field title.
The bottom line of this post, and this is a personal opinion, is don’t use the default dictionary that comes out of the box in the System. It’s a recommended practice to create your own dictionary node which will host dictionary folders and entries.
In that way, your fields’ title will be safe and you won’t see this issue anymore. Don’t forget to add the dictionary domain attribute into your site definition
<site="mywebsite" ...... dictionaryDomain="MY_DICTIONARY_ID" />
If you prefer to use patch files, then use this config:
<?xml version="1.0"?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <sites> <site name="mywebsite"> <patch:attribute name="dictionaryDomain">MY_DICTIONARY_ID</patch:attribute> </site> </sites> </sitecore> </configuration>
You can use the item path if you like.
I hope you enjoyed this post and don’t forget to share it.
Happy Sitecoring 😉