Sitecore’s constructs of item names and display names is useful for managing content and delivering content to end users in user-friendly ways. They can also be used to change the perceived names of template fields for a better user experience. John West recently published a blog post about the topic of Display Names, however I was already in the process of writing up this post, so here it is anyways. Read to on learn more about item names, display names, and how you can easily change the text labels for data template field names.
Item Names
Sitecore item names are — as you would expect — the names assigned to each Sitecore item. The names appear in the content tree and additionally translate to the resolved URL of the item by default.
You can determine the URL of an item by looking at the item’s path relative to the site’s start item:
Its typically best practice to name page items with hyphens between words for friendly URLs, instead of using spaces. Though this good for end users, it requires these item names in the tree to include hyphen as well, which can get annoying too. Luckily, Sitecore has a notion of another naming construct, display names.
Item Display Names
An item display name by default simply matches the item name, that is, until you fill in a value. Setting an item’s display name value will change the perceived name of the item in the content tree, but will preserve the original item name (likely with hyphens) for URLs. This allows the best of both worlds: friendly hyphenated URLs, and easy to read names in the content tree. It can also be automated.
Display Names and Language Specific URLs
Another nice advantage of being able to edit display names is that it allows a unique display name per language variant of an item. This is useful if an item has one perceived name in the tree for English and a separate name when looking at Spanish. This can be further used to actually render language-specific URLs based on the display name. By default, the Link Manager uses the item name to generate URLs, but you can simply swap the useDisplayName attribute to true if you want language-specific URLs on a multi-lingual site:
[xml]
<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="true" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" lowercaseUrls="false" shortenUrls="true" useDisplayName="true" />
[/xml]
Changing the Perceived Name of a Field
Though item names and display names are useful for regular content items, individual data template fields have their own ways to customize their names. There are two main ways to change the perceived name of a field:
- Change the “Title” field on the field item
- Fill in the Short Description on the field item
The most common way in the first approach — to set the Title field. In fact, most built-in fields do this as they typically start with “__” by the titles are changed to be more user-friendly. You can see this on the “__renderings” field which actually appears to be called “Renderings”:
The other approach is to set the Short Description on the field item. As you can see, by default the field name renders on the item:
First, navigate to Configure > Help on the field item itself:
Next, fill in the Short Description text which will render after the original field name:
As you can see, this can be quite useful to help content editors with instructional text without changing the actual field name.
Hi Mark – great post about the names…. I’m trying to actually set the tooltip (the last image on your post) programmitically, based on where the item is, however, I saw from testing the RenderSkinedContentEditor pipeline processor that the ItemField.ToolTip is readonly. Do you know of any pipelines I can hook into to change that on the fly?
Hi Mark, i am new to site core.
how can we set the dynamic value to the field.?
for example i have more then 5 countries sites , here i need to set the selected country value and language to the field.
This is a great post. It helped me customize the name of the field using Title. Thank you!!