0
votes

When editing a Sitecore item that contains HTML in the Display Name (e.g. Title), the HTML is encoded immediately. Editing Display Name a second time shows that <em>Title</em> has been converted to &lt;em&gt;Title&lt;/em&gt;.

We don't have any custom code that would do this; is there a configuration parameter or something that would control how display name is encoded?

[EDIT] To clarify, if I edit an item's Display Name to add HTML, and then edit it a second time, the HTML contained in the Display Name has been encoded. There are several older items that contain HTML in the Display Name field and it is rendered correctly.

For example, first I edit an item's Display Name to add emphasis tags...

Adding HTML

...you can see how the Display Name is updated in the content tree.

HTML updated

However, if I edit the item again, Sitecore encodes the HTML as show below...

HTML encoded

Oddly, there are other (older) items in the content tree that already have HTML in their Display Name, and the HTML is correctly rendered (see below item with tag in the display name).

Item with HTML in display name

My question is: what could cause the HTML to be encoded?

To answer the question "Why would you want to do this in the first place?", I would respond with the answer that this is legacy code that used to be working and is now suddenly not. I'm not building a new system; this is an existing web site that I'm troubleshooting.

1
I don't think this would make sense. The DisplayName is i.e. also shown in the Content Editor, where Bold and Italic wouldn't be great. Why would you like to do this? I would suggest you to create a new fields where you can insert what you want. - Kevin Brechbühl
Thanks for your response. I added screenshots and clarification to my question. - Bob Black

1 Answers

3
votes

Your question is a little bit confusing. What exactly are you expecting to see vs. what you are actually seeing? Display Name is a simple text field, it's not rich text... I don't believe Sitecore is doing any encoding here.

Now you can make Sitecore skip the decoding step for single-line text fields by removing the Sitecore.Pipelines.RenderField.GetTextFieldValue from the renderField pipeline. Then you'll get exactly whatever is in that field rather than &lt;em&gt;Title&lt;/em&gt;

OK, I think I get why your question is confusing me now. The input from you question was decoded?

EDIT: BTW, this pipeline entry GetTextFieldValue was a recent addition... some time between 6.3 and 6.6.