简体   繁体   中英

Liferay - get folder ID using folder name in velocity

I know how to get groupid in liferay velocity theme using:

#set ($scopeGroupId = $getterUtil.getLong($group_id))

However I also need to get a folder's ID using its name.
I have been researching for a while and don't seem to find a way to do that.

Is this enabled and feasible in ? 这在是否启用且可行?

Make sure that you are allowed to use serviceLocator or add in your portal-ext.properties this entry:

velocity.engine.restricted.variables=

After that you can use this code in your template:

#set ($folderLocalService =$serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFolderLocalService"))
#set ($folderId = $folderLocalService.getFolder($groupId,0,"folder_name").getFolderId())

$folderId 

Or you can use another method from DLFolderLocalService .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM