views:

308

answers:

2

Hi

We're having issues inserting links into rich text in Sitecore 6.1.0. When a link to a sitecore item is inserted, it is outputted as:

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

Rather than the actual resolved url:

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

This article confirms that this should be resolved in the render pipeline:

in Sitecore 6 it inserts a specially formatted link that contains the Guid of the item you want to link to, then when the item is rendered the special link is replaced with the actual link to the item

The pipeline has the method ShortenLinks added in web.config

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

So I really can't see why links are still rendering in ID format rather than as full SEO-tastic urls. Anyone got any clues?

Thanks, Adam

+1  A: 

This will be the default behaviour if you are using sc:fld to render field values. This is legacy behaviour left from Sitecore 5 which did not replace the guids in item links.

If you want to use Sitecore 6's new functionality, you must use sc:field instead

Nick Allen - Tungle139
To expand on this answer a bit, the <renderField /> pipeline is where links are "expanded" from the ID format mentioned into a full URL. The sc:field extension method invokes the renderField pipeline if you use XSL. If you're using code-behind to render links, you can use the FieldRenderer class. You can also use the FieldRenderer control in your layouts/sublayouts (or any other control derived from the FieldRenderer control).This document gives you a little background on the FieldRenderer control:http://sdn.sitecore.net/Reference/Sitecore%206/Presentation%20Component%20Reference.aspx
aweber1
Thanks, I'll have a read of that
adam
+1  A: 

If you are dealing with a large amount of code changes to implement FieldRenderer, might be worth to consider using Sitecore.Links.LinkManager.ExpandDynamicLinks(string text, UrlOptions options). It parses links and references to media items that Rich Text field might contain.

Julia