Sitecore Rich Text links not user friendly when re

2019-07-27 21:31发布

I have a component that includes a single Rich Text field. In the sublayout, the field is rendered as an Html.Editable with Glass so that it can be edited on the page in PageEditor. It looks like this:

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

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

However, when I insert links using the Rich Text editor, when the page is rendered (in normal view after being published, not in page editor), the links are rendered with the item ID rather than the user friendly path, like this:

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

I am pretty sure that this is an issue with Glass. How can I keep the field editable in the Page Editor but make it render the link correctly?

3条回答
我只想做你的唯一
2楼-- · 2019-07-27 21:54

You can check if you have proper 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

查看更多
戒情不戒烟
3楼-- · 2019-07-27 22:01

Can you try to change it from using literal to use Editable() method directly, Something like:

<%= Editable(GlassItem, x => x.Body) %>
查看更多
走好不送
4楼-- · 2019-07-27 22:15

I think Initialize() is too soon in the page life cycle. Try moving it further along, like to Page_Load() or so.

查看更多
登录 后发表回答