Sitecore Item Display Name is encoded automaticall

2019-06-13 20:52发布

问题:

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...

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

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

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).

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:

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.



标签: sitecore