cancel
Showing results for 
Search instead for 
Did you mean: 

How get current folder name in Share?

vescudero
Champ in-the-making
Champ in-the-making
Hi,

I want to get the name of the current documentLibrary folder when upload a document for to use in template flash-upload.get.html.ftl:


<tomcat>/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/upload/flash-upload.get.js
<tomcat>/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/upload/flash-upload.get.html.ftl


I have the following folder structure:

-documentLibrary
– Folder1
– Folder2
– Folder3

when enter a folder (for example, Folder1) I get the following path


http://localhost:8080/share/page/site/name-site/documentlibrary#filter=path|%2FFolder1|&page=1


and when I upload a document in this folder I would like to get the name of the current folder, in this case Folder1.

Is there a way to get the name of the current folder? Using javascript or freemarker. Pay attention that script flash-upload.get.js is executing on server not in client.

If using the param template.properties.container on flash-upload.get.html.ftl this returns the string documentLibrary but isn't I need.

Thanks
2 REPLIES 2

zladuric
Champ on-the-rise
Champ on-the-rise
The flash-upload.get.js renders on server, but you initialize the upload widget on the client. There's the
new Alfresco.getFileUploadInstance()
thing, and there is the setup of th instance. In that setup, you can set the container, or directly the nodeRef of the folder you're uplodaing to.

The default config is something like this:

{
siteId: siteId,
containerId: doclibContainerId,
path: docLibUploadPath,
filter: [],
mode: fileUpload.MODE_MULTI_UPLOAD,
}

<a href="http://sharextras.org/jsdoc/share/community-4.0.a/symbols/Alfresco.FileUpload.html#options">Here are</a> the details of the FileUpload instance configuration.

vescudero
Champ in-the-making
Champ in-the-making
Thanks for your response. But how could access this information for use in flash-upload.get.js? I want to get the name of the current folder when the dialog is open for to perform a check before displaying a list of content types.

Here is my code for my flash-upload.get.js:



model.contentTypes = getContentTypes();
model.currentFolder = getNameCurrentFolder(); /* This method should be able to get the name of the current folder of document Library where user upload a document receiving a param from flash-upload.js*/



And here is the flash-upload.get.html.ftl:


<select class="fileupload-contentType-select" tabindex="0">
               <#if (contentTypes?size > 0)>
                  <#list contentTypes as contentType>
                     <option value="${contentType.id}" <#if (("${msg(contentType.value)}" == "${currentFolder!}"))> selected="selected"</#if>>${msg(contentType.value)}</option>
                  </#list>
               </#if>
</select>