More in this section

Forums / Developing with Sitefinity / Insert a document dialog in the RTE

Insert a document dialog in the RTE

2 posts, 0 answered
  1. David van Geel
    David van Geel avatar
    59 posts
    19 Aug 2009
    08 Apr 2010
    Link to this post
    Hi All,

    Is it possible to have the "Insert a document" dialog in the RTE to return additional information like the file extension of the selected document? At the moment the result is a link like this.

    <a href="/Libraries/Dummy_Bestanden/Lorem_ipsum_dolor_sit_amet.sflb.ashx" sfref="[Libraries]cd72b569-8b13-4215-b2a6-cee9053f50e3">Lorem ipsum dolor sit amet</a>

    So -for instance- another attribute like this would be great.

    <a href="/Libraries/Dummy_Bestanden/Lorem_ipsum_dolor_sit_amet.sflb.ashx" sfref="[Libraries]cd72b569-8b13-4215-b2a6-cee9053f50e3" sfext="doc">Lorem ipsum dolor sit amet</a>

    Is this possible? Or is there another mechanism I should investigate?


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    12 Apr 2010
    Link to this post
    Hello David van Geel,

    It is possible.

    You should modify Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\DocumentEditorDialog.ascx
    InsertLink function as shown below and add an additional function - getExtension

    function getExtension(filename) {
          var ext = /^.+\.([^.]+)$/.exec(filename);
          return ext == null ? "" : ext[1];
      function insertLink() //fires when the Insert Link button is clicked
          var closeArgument = currentElement;
          selValue = document.getElementById('<%= selectedValueField.ClientID %>')
          editHolder = document.getElementById('<%= editHolder.ClientID %>');
          titleField = document.getElementById('<%= titleTxt.ClientID %>');
          var uplImg = document.getElementById('<%= uploadedDocument.ClientID %>');
          closeArgument.href = selValue.value;
          var fileExt = getExtension(titleField.value)
          closeArgument.setAttribute("ext", fileExt);
          closeArgument.innerHTML = titleField.value;
          if (selValue.value.indexOf("~/") == 0) {
              closeArgument.setAttribute("sfref", selValue.value);
          } else if (selectedItem != undefined && selectedItem.unresolved) {
              closeArgument.setAttribute("sfref", selectedItem.unresolved);
          } else if (uplImg != undefined && uplImg.attributes["sfref"] != undefined) {
              closeArgument.setAttribute("sfref", uplImg.attributes["sfref"].value);
          } else {
          var radWindow = getRadWindow();
          radWindow.argument = closeArgument;
          radWindow.close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.

    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.
2 posts, 0 answered