I am using sitecore 7 single site instance. Content editor is generating link to other sitecore pages in this format:
<a href="~/link.aspx?_id=C136420D804946BA83DEF823817F5944&_z=z">Agriculture</a>
after publishing link is not converted to the actual sever related URL. I have changed the link manager setting "alwaysIncludeServerUrl" to true but still not getting proper URL.
I have published the page but still not showing actual URL.
Update: I can't use field control here because there is some additional logic that controls what text needs to be rendered. for example, If there is page data source is defined then use that otherwise use "ContentBlock" field of the current item.
public string ContentBlockContent = "";
Sitecore.Data.Items.Item currentItem;
if (Parent is Sublayout && !string.IsNullOrEmpty(((Sublayout) Parent).DataSource))
{
currentItem = Sitecore.Context.Database.GetItem(((Sublayout) Parent).DataSource);
}
else
{
currentItem = Sitecore.Context.Item;
}
if (currentItem.Fields["ContentBlock"] != null)
{
ContentBlockContent = currentItem.Fields["ContentBlock"].ToString();
}
if (currentItem.Fields["PageContentSource"] != null)
{
var contentPageSource = currentItem.Fields["PageContentSource"];
var sourceItem = Sitecore.Context.Database.GetItem(contentPageSource.ToString());
if (sourceItem != null && sourceItem.Fields["ContentBlock"] != null)
{
ContentBlockContent = sourceItem.Fields["ContentBlock"].ToString();
}
}
and this is how "ContentBlockContnet" property is rendered on the page:
<%= ContentBlockContent %>
>>after publishing link is not converted to the actual sever related URL.
It’s not converted after publishing, it’s converted when page is rendered.
Make sure you render content fields using Sitecore render controls e.g. sc:text, sc:link or FieldRenderer
. In this way Sitecore will run the “renderField”
pipeline which take care about link conversion.