Foren
Velocity template DLFileEntry
Adri Meijer, geändert vor 9 Jahren.
Velocity template DLFileEntry
New Member Beiträge: 9 Beitrittsdatum: 14.03.12 Neueste Beiträge
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,
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,
Ryan Schuhler, geändert vor 9 Jahren.
RE: Velocity template DLFileEntry
Junior Member Beiträge: 77 Beitrittsdatum: 06.07.12 Neueste Beiträge
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:
If you want to use it you can set that setting to blank in your portal-ext.properties like this:
Hope that helps,
Ryan
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, geändert vor 9 Jahren.
RE: Velocity template DLFileEntry
New Member Beiträge: 9 Beitrittsdatum: 14.03.12 Neueste Beiträge
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,
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,
Tina Agrawal, geändert vor 9 Jahren.
RE: Velocity template DLFileEntry
Expert Beiträge: 297 Beitrittsdatum: 03.01.08 Neueste Beiträge
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
#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, geändert vor 9 Jahren.
RE: Velocity template DLFileEntry
New Member Beiträge: 9 Beitrittsdatum: 14.03.12 Neueste Beiträge
Thank you Tina
Bharamani P Tashildar, geändert vor 6 Jahren.
RE: Velocity template DLFileEntry
Junior Member Beiträge: 48 Beitrittsdatum: 27.08.14 Neueste Beiträge
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
#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
Sami Mikkonen, geändert vor 6 Jahren.
RE: Velocity template DLFileEntry
New Member Beiträge: 12 Beitrittsdatum: 06.07.12 Neueste Beiträge
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)) />
<#assign fileService = serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService")) />
<#assign files = FileService.getFileEntries(gid, fid, -1, -1, null)) />
gopal vaghasiya, geändert vor 6 Jahren.
RE: Velocity template DLFileEntry
New Member Beiträge: 5 Beitrittsdatum: 18.01.18 Neueste Beiträge
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
#set($static_images_folder = "/legalwiz-custom-theme/docroot/images")
but, it won't work
Give me suggestion
Thanks