Relatives links... :(

10 posts, 1 answers
  1. Samuel
    Samuel avatar
    2 posts
    Member since:
    Jul 2008

    Posted 18 Jul 2008 Link to this post

    Hello,

    I use "Telerik RadEditor for MOSS" and I have a problem with relative links.I use the "Hyperlink Manager" to add a link: I type my relative URL in the URL text field (for example: ./Help.aspx) and I choose the "Other" type. I click "OK".

    And finally, when I take a look to the generated HTML code, I haven’t my relative link but an absolute link has been created:
    http://xxx:port/website/Pages/Help.aspx

    I really need use a relative link because the website will be moved on a staging and after a production server... The absolute links will point on the development server pages...  :(

    Please, help me! Thanks!

    Regards,

    Samuel
  2. Answer
    Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 18 Jul 2008 Link to this post

    Hello Samuel,

    By default, Internet Explorer (IE) converts all relative links to absolute on the client. This behavior is due to the DOM engine of the Internet Explorer browser which “fills” the paths (href or src) for the objects in an editing area. Since RadEditor relies in most part to the Internet Explorer's engine, one may observe that the editor converts relative paths to absolute after switching to HTML mode and back to edit mode. Actually, it is Internet Explorer which is converting the links. This problem does not apply to NS/Mozilla/Firefox browsers. For v5, Telerik has employed a flexible mechanism based on regular expressions that strips absolute paths. For better performance the mechanism runs only when the user switches to HTML mode or submits the page. In order to enabled the editor absolute strip path filters you should open the ConfigFile.xml and ListConfigFile.xml files and set the StripAbsoluteImagesPaths and StripAbsoluteAnchorPaths properties to true, e.g.

      <property name="StripAbsoluteImagesPaths">true</property>
      <property name="StripAbsoluteAnchorPaths">true</property>


    Best regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  3. Samuel
    Samuel avatar
    2 posts
    Member since:
    Jul 2008

    Posted 30 Jul 2008 Link to this post

    Thanks Rumen ! You have solved my problem ! ;o)

    Best regards,

    Samuel
  4. Nick
    Nick avatar
    14 posts
    Member since:
    Aug 2008

    Posted 04 Aug 2008 Link to this post

    A couple of quick questions:

    1. Are these config settings listed above only available when RadEditor Lite is installed? I can't find these entries in the config files when using the trial version of RadEditor v5 -- is it configured to strip out absolute paths automatically, or do i need to change something else?
    2. Even when using RadEditor Lite (with the necessary config changes made) and i add a relative link to another page using the Telerik editor, it still prepends the domain name to the URL. I can tell this by switching to the code view.  If i manually remove the domain name from the URL while in the code view and save the content, it seems to maintain the relative link. This is great, except i obviously don't want to have to manually edit each hyperlink when entering new content.  Can you tell me if i'm missing something here?

    Thanks...

  5. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 05 Aug 2008 Link to this post

    Hello Nick,

    The StripAbsoluteAnchorPaths and StripAbsoluteImagesPaths are not used in the new version of the MOSS full featured editor (5.x). The Lite build is based on the old version (4.x) and it respects the above properties if you set them in the configuration file.

    If I understand correctly, you are using the Lite version and you have set the above properties to True. When you enter a relative URL, e.g. "/Pages/Default.aspx", the editor keeps it relative after you save the content. However, when you enter an absolute URL, e.g. "http://server/Pages/Default.aspx", the editor does not automatically convert it to be relative and it is kept absolute when you save the content. I think that this is the expected behavior - all URLs are kept the way you enter them. If you wish to force the editor to strip certain absolute paths, you need to use the AnchorPathToStrip property - http://www.telerik.com/help/aspnet/editor/radeditor-telerik.webcontrols.radeditor-anchorpathtostrip.html


    Kind regards,
    Lini
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Nick
    Nick avatar
    14 posts
    Member since:
    Aug 2008

    Posted 05 Aug 2008 Link to this post

    To clarify, whether i'm using the lite or the full version of RadEditor, it is still adding the domain name to my relative links.  This is the same behaviour that is exhibited by the built-in Microsoft editor with Internet Explorer.

    I think this is because the Hyperlink Manager button on my RadEditor instance still fires up the original Microsoft dialog -- not the Telerik one.  Is this a config setting i need to change?

    NB: If i insert an image it uses the Telerik RadWindow dialog.
  7. Nick
    Nick avatar
    14 posts
    Member since:
    Aug 2008

    Posted 05 Aug 2008 Link to this post

    The tooltip on the Hyperlink button in my editor actually says "MOSSLinkManager" -- not "Hyperlink Manager".
  8. Nick
    Nick avatar
    14 posts
    Member since:
    Aug 2008

    Posted 05 Aug 2008 Link to this post

    Solution: You need to edit the RadEditor tools configuration file to instruct the RadEditor to use its built-in Hyperlink Manager tool instead of Microsft's MOSS Hyperlink Manager tool.

    Configuration file located here:

    C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\RadEditorSharePoint\5.2.0.0__1f131a624888eeed\Resources\ToolsFile.xml

    More details here:

    http://www.telerik.com/help/aspnet-ajax/difference-between-internal-editor-and-moss-dialogs.html
  9. Alan
    Alan avatar
    1 posts
    Member since:
    Dec 2008

    Posted 15 Dec 2008 Link to this post

    If you want to stick with the MOSS Hyperlink Manager tool, there is a great solution to this posted by Stanimir of the Telerik team at:

    http://www.telerik.com/community/forums/sharepoint-2007/full-featured-editor/absolute-urls-to-images-documents.aspx#680247
    detail from link posted below:

    1. You should use the OnClientLoad property of the RadEditor to attach a handler. To do this you should add the following line in the ConfigFile.xml
    <property name="OnClientLoad">OnClientLoad</property>  

    2. You can use MOSSEditorTools.js to add custom java script code to RadEditor. There you should define the OnClientLoad handler and your custom content filter.
    Here is an example that you may find useful:

    function OnClientLoad(editor, args) 
    {     
        editor.get_filtersManager().add(new MyFilter()); 
     
    MyFilter = function() 
        MyFilter.initializeBase(this); 
        this.set_isDom(false); 
        this.set_enabled(true); 
        this.set_name("RadEditor filter"); 
        this.set_description("RadEditor filter description"); 
    MyFilter.prototype = 
        getHtmlContent : function(content) 
        {                       
            var newContent = content
             
            //here you replace absolute URL
            newContentnewContent = newContent.replace(/http:\/\/mossrtm\//g, ""); 
            return newContent; 
        }, 
     
        getDesignContent : function(content) 
        {                       
            var newContent = content
            return newContent; 
        }        
                 
    MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter); 

    Just add this code at the end of MOSSEditorTools.js .

    Once you follow these steps, the absolute part of the URL should be stripped.
  10. Stanimir
    Admin
    Stanimir avatar
    1653 posts

    Posted 15 Dec 2008 Link to this post

    Hello Alan,

    There is a small javascript error in the code bellow. It was caused by the Format Code Block tool. I forgot to specify the language.

    You need to replace
    newContent
    newContent = newContent.replace(/http:\/\/mossrtm\//g, "");

    with
    newContent = newContent.replace(/http:\/\/mossrtm\//g, "");


    Greetings,
    Stanimir
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top