Posted by: kendomen | March 19, 2010

Jive4: Step-by-Step Adding Extra Fields to User Profile

Here’s a simple step-by-step example of getting extra user attributes to display on the quick user pop-up in Jive4.  I wrote this for Walt Austin who is a friend of Jennifer Bouani.

Suppose you have extra fields like this:

You want to be able to display that in your quick pop-up just like the full user profile:

Override the theme called view-profile-short.ftl

<ul>

<#if targetUserProfile.title?has_content>
<li><strong><@s.text name=’settings.title.label’ /><@s.text name=’global.colon’ /></strong> ${targetUserProfile.title?html}</li>
</#if>
….
</#if>
</li>
<#else>
<li><strong><@s.text name=’settings.emailaddr.label’ /><@s.text name=’global.colon’ /></strong> <@s.text name=”settings.private.text” /></li>
</#if>
<li><strong>let’s add stuff here…</strong></li>
<@displayProfileFields fields=fields viewingSelf=viewingSelf/>

</ul>
</#if>

The key is this line:

<@displayProfileFields fields=fields viewingSelf=viewingSelf/>

It’s just a macro that picks up your extended fields and displays it in the pop up.

Make sure to include this on the top of this ftl:

<#include “/include/profile-macros.ftl”  />

(Note:  the path above may be wrong depending on your particular environment)

Advertisement

Responses

  1. Ken – Brilliant work, my friend. :) Love the step-by-step tutorial. Walt and I thank you very much. Walt – because he doesn’t have to do the code himself and me because I can now craw out of hiding and face our users who’ve been begging me for it.

    (btw – King Leonidas needs to go on a diet)

    Have a great weekend!

  2. Hi Ken,
    Thanks again for walking through this. I have implemented what you suggested however the “fields” value is null if you add: to the view-profile-short.ftl. I can add the Company field like you have in your other blog:
    Company: ${targetUserProfile.company?html})
    This works because the variable Company exists on the UserProfile object.

    When I try to access custom fields, they do not display because the “fields” variable is null. Which class are you overriding in your plugin to access the “fields” variable?

    I see that the ViewProfileShort class extends the ViewProfile class (which has the populates the “fields” variable in the execute() method), but ViewProfileShort overrides the method without populating that method. Are you basically calling super.execute() to get this populated?

    Thanks,
    Walt

    • Walt, give me a call. I’m sorry I didn’t respond sooner.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.