【问题标题】:Sitecore not resolving rich text editor URLS in page rendersSitecore 无法解析页面呈现中的富文本编辑器 URL
【发布时间】:2011-01-14 20:31:57
【问题描述】:

我们在 Sitecore 6.1.0 中将链接插入富文本时遇到问题。当插入到站点核心项目的链接时,它会输出为:

http://domain/~/link.aspx?_id=8A035DC067A64E2CBBE2662F6DB53BC5&_z=z

而不是实际解析的url:

http://domain/path/to/page.aspx

This article 确认这应该在渲染管道中解决:

在 Sitecore 6 中,它特别插入了一个 包含 Guid 的格式化链接 您要链接到的项目,然后 当项目呈现特殊 链接替换为实际链接 到项目

管道在web.config中添加了ShortenLinks方法

<convertToRuntimeHtml>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.PrepareHtml, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.ShortenLinks, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.SetImageSizes, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.ConvertWebControls, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.FixBullets, Sitecore.Kernel"/>
    <processor type="Sitecore.Pipelines.ConvertToRuntimeHtml.FinalizeHtml, Sitecore.Kernel"/>
</convertToRuntimeHtml>

所以我真的不明白为什么链接仍然以 ID 格式呈现,而不是完整的 SEO-tastic url。谁有线索?

谢谢,亚当

【问题讨论】:

    标签: url hyperlink sitecore pipeline rte


    【解决方案1】:

    如果您使用 sc:fld 呈现字段值,这将是默认行为。这是 Sitecore 5 遗留的遗留行为,它没有替换项目链接中的 guid。

    如果你想使用 Sitecore 6 的新功能,你必须使用 sc:field 来代替

    【讨论】:

    • 为了稍微扩展这个答案, 管道是将链接从提到的 ID 格式“扩展”为完整 URL 的地方。如果您使用 XSL,sc:field 扩展方法将调用 renderField 管道。如果您使用代码隐藏来呈现链接,则可以使用 FieldRenderer 类。您还可以在布局/子布局(或从 FieldRenderer 控件派生的任何其他控件)中使用 FieldRenderer 控件。本文档为您提供有关 FieldRenderer 控件的一些背景知识:sdn.sitecore.net/Reference/Sitecore%206/…
    【解决方案2】:

    如果您正在处理大量代码更改以实现 FieldRenderer,则可能值得考虑使用 Sitecore.Links.LinkManager.ExpandDynamicLinks(string text, UrlOptions options)。它解析富文本字段可能包含的媒体项目的链接和引用。

    【讨论】:

    • 如果您使用的是代码生成架构,在这种架构中您依赖原始字段值并希望替换链接,那么使用建议的功能仍然很有效。
    【解决方案3】:

    我也遇到了类似的情况。我的客户使用的是 sitecore 占位符,它也不能正确呈现链接。正如我使用字段渲染结束的答案所述:

    <sc:FieldRenderer runat="server" ID="frBody" FieldName="Body"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多