In EPiServer 8, as per this document (see section "PageData.LinkURL and classic links"), permanent links (~/link/bbaadfc8-44d8-42a6-b559-b20f08714084.aspx are being returned from APIs, such as PageData.LinkURL, and the URL is always determined via routing to the Friendly URL at rendering time.
Now I have html something like this
The image (EPiServer property) setup as a background for the li never gets converted to friendly.
Is there anyway I can override this so it also gets converted into friendly like the img tag inside the li?
if its a mvc application@Url.ContentUrl(Model.Url)should return you freindly urls
It is a webform application. The quick and dirty way will be to write an extension method something like
public static string GetFriendlyUrl(this Url internalUrl)
string url = string.Empty;
if (internalUrl == null || string.IsNullOrEmpty(internalUrl.ToString())) return url;
var urlHelper = ServiceLocator.Current.GetInstance<UrlHelper>();
var friendlyUrl = urlHelper.ContentUrl(internalUrl.ToString());
and instead of writing
<li style="background: url(<%= this.CurrentBlock.BackgroundImage %>) no-repeat 0 0;" >
<li style="background: url(<%= this.CurrentBlock.BackgroundImage.GetFriendlyUrl() %>) no-repeat 0 0;" >
But I don't want to do that. I want to override the rendering mechanism so that I don't have to do this at all the places and can handle it at a single centeralized place
You can add a readonly property in your block to render url as you want and use that property instead.Regards/K