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).
Asked
Active
Viewed 1,154 times
0
-
What do you mean by the "opened document"? The document details page? A document you downloaded some time ago? Something else? – Gagravarr Jun 20 '13 at 08:28
-
Yes I mean the document details page. – Kanishka Dilshan Jun 20 '13 at 12:08
1 Answers
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