0

I am planning to generate direct download link from the client side when user open a document in document details window. In order to do that I want to access noderef of the opened document. Can someone mention how to access noderef of the opened document from alfresco share client side (javascript).

Kanishka Dilshan
  • 724
  • 2
  • 10
  • 19

1 Answers1

1

Good for you that I've done that in the past for a customer.

You'll need to change the following files (create a module or just override them)

  • document-links.get.properties (add a new label for download)
  • document-links.get.head.ftl (include your new overridded client side JavaScript)
  • document-links.get.html.ftl (add a new field like the current page url)

        <h3 class="thin dark">${msg("page.download")}</h3>
        <div class="link-info">
           <input id="${el}-download" value="${document.node.contentURL}"/>
           <a href="#" name=".onCopyLinkClick" class="${el} hidden">${msg("page.copy")}</a>
        </div>
    
  • document-links.js (client side JavaScript)

onReady: function DocumentLinks_onReady() { // Display copy links if (this.hasClipboard) { Dom.removeClass(Selector.query("a.hidden", this.id), "hidden"); }

 // Make sure text fields auto select the text on focus
 Event.addListener(Selector.query("input", this.id), "focus", this._handleFocus);

 // Prefix some of the urls with values from the client
 Dom.get(this.id + "-page").value = document.location.href;

 // added Download link
 var contentURL = Dom.get(this.id + "-download").value;
 Dom.get(this.id + "-download").value = window.location.protocol + "//" + window.location.host + "/alfresco/d/a" +

contentURL.replace('api/node/content/', ''); }

Tahir Malik
  • 6,623
  • 15
  • 22