Sitecore Rich Text links not user friendly when rendered through Glass

為{幸葍}努か 提交于 2019-12-24 07:16:57

问题


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?


回答1:


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




回答2:


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

<%= Editable(GlassItem, x => x.Body) %>



回答3:


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



来源:https://stackoverflow.com/questions/38150776/sitecore-rich-text-links-not-user-friendly-when-rendered-through-glass

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