Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: Get url files from a folder id from documents and media in ftl template
Hi guys
I´m trying to show every image stored in a folder of my Documents and media library in a freemarker template DXP 7.3.
So, how can I get every file of that folder? Assuming that in the structure for that template I have a text field to put the folderId or folderUrl that I want to travel in search of it´s child files.
I would really appreciate any help you can offer me.
Take a look at method getFileEntries of the DLFileEntryLocalService
Thks. I´ll look into it.
I resolved with this code:
<#if folderId.getData()?has_content>
<#assign groupId = themeDisplay.getScopeGroupId()/>
<#assign dlFileEntry = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService") />
<#assign files =dlFileEntry.getFileEntries(groupId,folderId.getData()?number) >
<#list files as item>
<img src="${themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + themeDisplay.getScopeGroupId() + "/" + item.getUuid()}">
<br>
</#list>
</#if>
Hope this get usefull to others..
Hi Ernesto,
Here is how we are doing it in our freemarker templates.
<#assign
dlAppLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppLocalService")
dlFileEntryLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")
folder = dlAppLocalService.getFolder(themeDisplay.getCompanyGroupId(), 0, "FOLDER-NAME")
fileEntries = dlFileEntryLocalService.getFileEntries(themeDisplay.getCompanyGroupId(), folder.getFolderId())
/>
Thnks for your reply!