Foros de discusión

Velocity template DLFileEntry

Adri Meijer, modificado hace 9 años.

Velocity template DLFileEntry

New Member Mensajes: 9 Fecha de incorporación: 14/03/12 Mensajes recientes
Hello,

I want to use this template, but it doesn't work (see below).

## instance of DLFileEntry service
#set($fileService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))

## get group id
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))

##search documents by folderId
#set($fid = $getterUtil.getLong($folder.folderId))
#set($files = $FileService.getFileEntries($gid, $fid, -1, -1, null))

#foreach($doc in $files)
<p>$doc.getTitle()</p>
#end

<p>$gid</p>
<p>$fid</p>
<p>$files</p>

I am using Liferay 6.2 CE ga2. The variables $gid and $fid can be found.
I guess that this line #set($files = $FileService.getFileEntries($gid, $fid, -1, -1, null)) is not correct for Liferay 6.2.

Can anyone help me ?

Regards,
thumbnail
Ryan Schuhler, modificado hace 9 años.

RE: Velocity template DLFileEntry

Junior Member Mensajes: 77 Fecha de incorporación: 6/07/12 Mensajes recientes
Hey Adri,

My initial guess would be that the $serviceLocator variable is not set. You can check this just by printing out $serviceLocator on the page and see if it works.

In Liferay 6.2 the service locator is a restricted variable by default. If you look in portal.properties you can see:
velocity.engine.restricted.variables=serviceLocator


If you want to use it you can set that setting to blank in your portal-ext.properties like this:
velocity.engine.restricted.variables=


Hope that helps,
Ryan
Adri Meijer, modificado hace 9 años.

RE: Velocity template DLFileEntry

New Member Mensajes: 9 Fecha de incorporación: 14/03/12 Mensajes recientes
Hello Ryan,

Thanks for your reply. The solution you gave me does not work. The service locator can determine the variable (@bf308f3)

Web Content Display
Options
Gid :10181
Fid :0

$files

Service Locator :com.liferay.portal.template.ServiceLocator@bf308f3

The problem is that $files are not found. The $files gave in this example mutiple file names.

#set($files = $FileService.getFileEntries($gid, $fid, -1, -1, null))

#foreach($doc in $files)
<p>$doc.getTitle()</p>
#end

Regards,
thumbnail
Tina Agrawal, modificado hace 9 años.

RE: Velocity template DLFileEntry

Expert Mensajes: 297 Fecha de incorporación: 3/01/08 Mensajes recientes
Is this a typo -

#set($fileService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set($files = $FileService.getFileEntries($gid, $fid, -1, -1, null))

The set defines a fileService with small F. And when you access you call $FileService

Tina
Adri Meijer, modificado hace 9 años.

RE: Velocity template DLFileEntry

New Member Mensajes: 9 Fecha de incorporación: 14/03/12 Mensajes recientes
Thank you Tina
thumbnail
Bharamani P Tashildar, modificado hace 6 años.

RE: Velocity template DLFileEntry

Junior Member Mensajes: 48 Fecha de incorporación: 27/08/14 Mensajes recientes
Hi Tina,

#set($fileService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set($files = $FileService.getFileEntries($gid, $fid, -1, -1, null))

how to write above two lines in liferay 7 using freemarker.

Can you please help in this?

Thanks
thumbnail
Sami Mikkonen, modificado hace 6 años.

RE: Velocity template DLFileEntry

New Member Mensajes: 12 Fecha de incorporación: 6/07/12 Mensajes recientes
I would try something like this:
<#assign fileService = serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService")) />
<#assign files = FileService.getFileEntries(gid, fid, -1, -1, null)) />
gopal vaghasiya, modificado hace 6 años.

RE: Velocity template DLFileEntry

New Member Mensajes: 5 Fecha de incorporación: 18/01/18 Mensajes recientes
I want to create custom velocity variable for $images_folder, so I was created like below in init_custom.VM file.

#set($static_images_folder = "/legalwiz-custom-theme/docroot/images")
but, it won't work

Give me suggestion

Thanks