Sitecore links inserted in Rich Text editor are not resolved to user friendly URLs

北慕城南 提交于 2019-12-11 05:32:47

问题


I saw this post but I'm not sure how to actually apply the answers.

I have a basic template that just has one Rich Text field called Body. The layout looks like this:

<div style="min-height: 38px">
    <asp:Literal runat="server" ID="litBodyContent"/>
</div>

I place it on the page with the Page Editor and enter some text into it. When I insert a link, it inserts it using the item ID rather than resolving it to a user friendly path:

<a href="~/link.aspx?_id=D9D103AD60DA4B318521801ADA863222&amp;_z=z">Go to another page</a>

when it should look like

<a href="/blog/2016/february/erica-test-entry">Go to another page</a>

What do I need to do to make the Rich Text editor resolve user friendly URLs?

Edit: Here's the codebehind for the Body Text

public override void Initialize()
{
    litBodyContent.Text = Html.Editable(GlassItem, item => item.Body);
}

Edit 2: This is one component that uses the Rich Text field, but I really need a universal fix so that any component that uses the Rich Text field will render links correctly. I don't want to have to manually fix every place that has a Rich Text field.


回答1:


It may be due to the attribute in the model.

If you have SitecoreFieldSettings.RichTextRaw attribute, it will NOT pass through render pipeline and returns the RAW HTML. Instead if you use Default (SitecoreFieldSettings.Default), rich text content will go through render pipeline and url will be in friendly format.

http://docs.glass.lu/html/d44739b2-5f0e-d862-f62c-86c50f0b262f.htm

https://stackoverflow.com/a/43261752/3016347



来源:https://stackoverflow.com/questions/38147672/sitecore-links-inserted-in-rich-text-editor-are-not-resolved-to-user-friendly-ur

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!