21 January, 2013

User service in webcontent template

If you want to get list out user data in liferay web content template, use just below velocity template code in web content template and get work out :

 ## Don't forget to set journal.template.velocity.restricted.variables=
 ## in portal-ext.properties; in other words, set it to nothing to unset the restriction.
 ##

#set ($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($userId = $getterUtil.getLong($request.remote-user))
#set($user = $userLocalService.getUserById($userId))



#set ($userFirstName=$user.getFirstName())

## to get expando values from gradYear,UndergradSchool
#set ($class_year = $user.getExpandoBridge().getAttribute("gradYear").get(0))
#set ($ugrad = $user.getExpandoBridge().getAttribute("UndergradSchool"))

#set ($userCount=$userLocalService.getUsersCount())

<p>Year: $class_year</p>
<p>School: $ugrad</p>
<p>First Name: $userFirstName</p>
<p>User count: $userCount </p>

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...