Displayname (2)

Dear Derek Roberti,

First of all I’m glad to see you blogging. And you spend a lot of time on good post. This time I just want to add a note which should be common knowledge for all Sitecore Developer. Alex Shyba wrote a comment, but I would expand this a little.

The DisplayName of a Sitecore item is actually the friendly title which should be known by all users, developers and administrators. The DisplayName is just the friendly name(as you describe in your post). When you want to generate an path by yourself, you even got the option to use Item.Paths.GetPath(Item item, string seperator, ItemPathType.DisplayName).

Also, in nearly all cases you should use Item.DisplayName rather then Item.Name. Actually, the DisplayName-property is implemented in this way:

        public string DisplayName
        {
            get
            {
                string str = base[FieldIDs.DisplayName];
                if (str.Length > 0)
                {
                    return str;
                }
                return Name;
            }
        }

This means there’s a fallback scenario for the DisplayName.
Next to it, users can decide in there Content Editor settings wether they want to see the DisplayName in the tree or just the item-Name.

In different solution I often see developer create Title-fields. I would strongly suggest to use the DisplayName for those cases. As it will adjust to the Sitecore thoughts.
It might be good to spend some time at a customer and look how we are able to make sure the DisplayName-button can be recognized and found in a more usable way. I guess a lot of people just look over it.

A nice hint for the experienced Sitecore users. You can always quickly rename the item by hitting F2. The DisplayName doesn’t have a shortcut. You could set this up by changing /sitecore/system/ribbons/chunks/rename/displayname. Set the KeyCode to 114(rather change it to F6, 117 as F3 is reserved for searching) for F3. Other keys could be resolved using the KeyboardMap application in Sitecore.

Thank you again for your clear post. Hopefully you think this post is a nice addition :).

– Alex