Laliwala IT Services

Laliwala IT Services
Website Development

Monday, February 21, 2011

liferay portlet, How to get user/owner of a page in vm?

liferay portlet
liferay portlet
Oliver Bayer : Hi,


in my theme I want to get the owner (the user object) of a page in portal-normal.vm to show the user name in the page title. But I don't know by which method and by which parameter I can achieve this: plid, friendlyurl, groupid?
Any hints are appreciated.
Oli
Man V K : Hi,
Have you tried this,look themes\_unstyled\templates\init.vm, you will get idea.
#set ($user_id = $user.getUserId())

#set ($is_default_user = $user.isDefaultUser())

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

#set ($user_middle_name = $user.getMiddleName())

#set ($user_last_name = $user.getLastName())

#set ($user_name = $user.getFullName())

#set ($is_male = $user.isMale())

#set ($is_female = $user.isFemale())

#set ($user_birthday = $user.getBirthday())

#set ($user_email_address = $user.getEmailAddress())

#set ($language_id = $user.getLanguageId())

#set ($time_zone = $user.getTimeZoneId())

#set ($user_greeting = $htmlUtil.escape($user.getGreeting()))

#set ($user_comments = $user.getComments())

#set ($user_login_ip = $user.getLoginIP())

#set ($user_last_login_ip = $user.getLastLoginIP())

#set ($user_group = $user.getGroup())

#set ($user_organizations = $user.getOrganizations())
Ciao

Vin kk
Oliver Bayer : Hey Vin,
thanks for answering.
To say it more precisely: I don't want to get the actual logged in user but the owner of the page the actual user is at atm (if it's a user page and not a community). I need the owner name to print it to the title-tag of the page.
Oli
Mazhar Anwar : You can get creator user Id with "$layout.getGroup().getCreatorUserId()".
Further if you want you can get user object with above userId.
Regards,

Mazhar
Oliver Bayer : Hi Mazhar,
cool, this could be the solution. Thanks!
But I don't know why this code-snippet works emoticon.
As far as I understand this method it returns the creator of the page NOT the owner. But it seems to work for userpages although the users don't create the pages by themself but get them created via group membership.
Greets Oli

No comments:

Post a Comment