Quantcast
Viewing all articles
Browse latest Browse all 25

Sitecore Item and Field Names

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.

Image may be NSFW.
Clik here to view.
item-name

Image may be NSFW.
Clik here to view.
item-url

You can determine the URL of an item by looking at the item’s path relative to the site’s start item:

Image may be NSFW.
Clik here to view.
item-path

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.

Image may be NSFW.
Clik here to view.
item-and-display-names

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:

<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" />

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:

  1. Change the “Title” field on the field item
  2. 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”:

Image may be NSFW.
Clik here to view.
field-title

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:

Image may be NSFW.
Clik here to view.
sample-field

First, navigate to Configure > Help on the field item itself:

Image may be NSFW.
Clik here to view.
field-help-settings

Next, fill in the Short Description text which will render after the original field name:

Image may be NSFW.
Clik here to view.
field-tooltip

As you can see, this can be quite useful to help content editors with instructional text without changing the actual field name.

Image may be NSFW.
Clik here to view.
updated-item-field

Sitecore Item and Field Names is a post from Fire Breaks Ice, published by Mark Ursino, Sitecore MVP


Viewing all articles
Browse latest Browse all 25

Trending Articles