EPiSevrer CMS 8 friendly URL query

Vote:
 

Hi guys,

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?

    Many thanks

    #123696
    Jul 15, 2015 15:53
    Vote:
     

    if its a mvc application
    @Url.ContentUrl(Model.Url)
    should return you freindly urls

    Regards
    /K

    #123699
    Jul 15, 2015 16:59
    Vote:
     

    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());
    return friendlyUrl;
    }


    and instead of writing

    <li style="background: url(<%= this.CurrentBlock.BackgroundImage %>) no-repeat 0 0;" >


    Write

    <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

    #123700
    Edited, Jul 15, 2015 17:12
    Vote:
     

    You can add a readonly property in your block to render url as you want and use that property instead.

    Regards
    /K

    #123706
    Jul 16, 2015 11:31
    * You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.