1

I'm trying to get the profile picture of my users and display it in my liferay theme. So far I've been able to access the User object trough the velocity $user variable. The user model has a method called getPortraitUrl() which takes ThemeDisplay as a parameter. I've read in the liferay documentation that the themeDisplay object is available at runtime when working with themes, but I can't seem to make this work.

I've tried several different ways to get the themeDisplay object and none of them seem to work:

  • $theme
  • $themeDisplay
  • $request.get("theme-display")
  • $theme_display

... and several other methods that return nothing.

$user.getPortraitUrl($themeDisplay) is what I'm trying to achieve.

Any help would be greatly appreciated

mduck
  • 197
  • 1
  • 6
  • 23

2 Answers2

5

Be careful that the correct method is getPortraitURL(ThemeDisplay themeDisplay), URL is in uppercase.

Try this:

$user.getPortraitURL($themeDisplay)


You should also be able to use $themeDisplay.
Access Objects from Velocity is useful link for all liferay velocity variables.

Sticcio
  • 196
  • 5
0

The variable you need to use for ThemeDisplay is

$theme_display

Ankit P
  • 534
  • 4
  • 12
  • Yeah, I tried that one too and didn't work. Could it be that the use of this variable is disabled somewhere in liferay's properties files? I'm totally lost on this one. – mduck Oct 01 '13 at 16:10
  • I assume you are logged in try adding below in your vm $theme_display $user $user.getPortraitURL($theme_display) It should display $theme_display as a object and entire user details for logged in user and Portrait URL like /image/user_male_portrait?img_id=0&t=1380865596111. It worked for me. Which version of Liferay you are using ? – Ankit P Oct 04 '13 at 05:50