+1-888-365-2779
Try Now
More in this section

Absolute URLs

8 posts, 0 answered
  1. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    29 Sep 2010
    Link to this post
    Hi is it possible to setup Sitefinity's Generic Content Editor so that image URLs will automatically be fully qualified?

    Thanks!
    Devin
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Sep 2010
    Link to this post
    Hi Devin,

    The Generic Content control works with dynamic links that are resolved depending on the host. Generally it is better no to change the dynamic links ( links created from items from Images and Documents module). There is a method that you can use to resolve the links to absolute url

    ResolveLinks(string html, GetItemUrl itemUrl, ResolveUrl resolveUrl, bool preserveOriginalValue, bool resolveAsAbsoluteUrl)

    • "html"-Source HTML text.
    • "itemUrl" -Delegate for processing item information. Must return the item URL.
    • resolveUrl" -Delegate for processing unresolved URL. Must return resolved URL.
    • preserveOriginalValue" - If true the original value of altered attributes is preserved in additional attribute named sfref.
    • resolveAsAbsoluteUrl"  -  If true, URLs are resolved as absolute paths, including protocol and domain name.
    To resolve the url to absolute you have to override RenderTextContent method of GenericContent control.

    Here is a sample code

    public override void RenderTextContent(System.Web.UI.HtmlTextWriter writer)
        {
            if (this.SharedContent.Status == ContentStatus.Published
                    || this.SharedContent is StagedContent)
            {
                string text = (string)this.SharedContent.Content;
                if (this.SharedContent is IDynamicLinkContainer
                    && ((IDynamicLinkContainer)this.SharedContent).HasDynamicLinks)
                    text = LinkParser.ResolveLinks(text, ContentManager.ResolveItemUrl, null, this.DesignMode, true);
                writer.Write(text);
            }
        }


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    01 Oct 2010
    Link to this post
    Hi Ivan,
    Is there a way to do this with images?  For example, I want an image with a path "/images/test.png" to resolve to "http://www.mydomain.com/images/test.png".

    Thanks!
    Devin
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Oct 2010
    Link to this post
    Hi Devin,

    The ResolveLinks  accepts dynamic links - [Provider]GUID and depending on the value the url is resolved for the proper provider. If you pass a dynamic link and set resolveAsAbsoluteUrl to true the url should be resolved with the current host.

    Another option is appending the url host from the HttpContext to the location of your png.

    If you link the images by href or src attributes you can use MakeUrlsAbsolute content filter of the RadEditor control.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    04 Oct 2010
    Link to this post
    Hi Ivan,
    I'm currently trying to implement this in the Events module.  It's mostly working for images but the sfref is causing image paths to be relative instead of absolute.  Is there a way that I can prevent RADEditor from adding the sfref code or strip it?

    Thanks!
    Devin
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Oct 2010
    Link to this post
    Hello Devin,

    sfref is added by us, not by the RadEditor. The tag cannot be removed, because this an identifier that we use to resolve the dynamic links. The attribute is used by ImageEditorDialog, DocumentEditorDialog, LinksEditorDialog, ButtonSelector. Removing the attribute means that these dialogs will not work properly anymore.
    Generally using absolute links is not a good practice and if you move the website on another host - event for some development all these links will be broken, because they will point to the other host which has been used when you have set the links.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Devin
    Devin avatar
    149 posts
    Registered:
    09 Jun 2009
    05 Oct 2010
    Link to this post
    Hi Ivan,
    Perhaps I haven't been clear.  I want to use absolute URLs and remove the sfref because my client wants to copy the HTML from the page and paste it into their email newsletter.  Is there a way to do this?

    Thanks,
    Devin
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Oct 2010
    Link to this post
    Hello Devin,

    You can use our newsletters module which works with dynamic links, otherwise you need a custom dialogs that do not add sfref attribute and resolve the url to absolute. You can turn off the custom dialogs from Sitefinity/Admin/ControlsTempaltes/EditorToolsFile.xml and use the default one that comes with RadEditor control, but you will not be able to select items from Sitefinity - pages, images etc. 

    Another option is creating a custom tool for RadEditor and use
    methods to get the html (that contains sfref attribute and relative path) and modify it as you want. In this case when you want to paste some text to your newsletter you have to use the custom button/tool for "copy/pasting".

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
8 posts, 0 answered