Re: [xwiki-users] Display "List of Users" Type in User Directory

2015-05-17 Thread Sergiu Dumitriu
Whenever something doesn't work, check the type of the variables you have:

$value.class

In this case, it would print java.lang.String, which means that the
value is a plain string, so it doesn't have any get(property) method.

You want to turn that string into some kind of user. Try this:

{{velocity}}{{html clean=false}}
#set ($userObj = $xwiki.getDocument($value).getObject('XWiki.XWikiUsers'))
$value.get('first_name') $value.get('last_name')
{{/html}}{{/velocity}}

But it's even simpler this way:

{{velocity}}$xwiki.getUserName($value, false){{/velocity}}

The false parameter means "wrap the username in an HTML link to the
user's profile". If you just want a plain name, then keep that as
"false". A link means that it will generate HTML, and depending on which
version of XWiki you have, you might need to fiddle with the settings of
the livetable, things get complicated.

On 05/17/2015 10:20 AM, hubert wrote:
> Dear all,
>  
> I'd like to add to the user directory a field that shows the line manager of
> the user. 
> The line manager himself is also a XWiki user so the presentation should be
> like
> first_name +" "+ last_name with a hypelink to the profile page.
> 
> Now I have problems with the presentation of the line manager.
>  
> My approach was:
> 1) Modify the class XWiki.XWikiUsers:
> 1.1) Add a field 'superior' of type 'List of Users'
> 1.2) Modify 'Custom Display' of field 'superior' as following:
>   {{velocity}}
>  {{html clean=false}}
>  $value.get('first_name') $value.get('first_name')
>   {{/velocity}}}
> 2) Modify the Selected Columns list for 'User Directory':
>first_name last_name superior
>  
> With the code above in 1.2, in the User Directory Panel my column 'superior'
> is always
> $value.get('first_name') $value.get('first_name')}
> 
> When I use in 1.2:
> {{velocity}}
>$value
> {{/velocity}}
> I get at least the following output (when superior is 'hkraut')
> XWiki.hkraut
> 
> Please can somebody tell me, if already point 1.1 was the wrong approach?
> Or how can I adapt 1.2 to display the superior properly?
>  
> Many thanks,
> Hubert
> 
> 
> 
> --
> View this message in context: 
> http://xwiki.475771.n2.nabble.com/Display-List-of-Users-Type-in-User-Directory-tp7594876.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
> 


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Display "List of Users" Type in User Directory

2015-05-17 Thread hubert
Dear all,
 
I'd like to add to the user directory a field that shows the line manager of
the user. 
The line manager himself is also a XWiki user so the presentation should be
like
first_name +" "+ last_name with a hypelink to the profile page.

Now I have problems with the presentation of the line manager.
 
My approach was:
1) Modify the class XWiki.XWikiUsers:
1.1) Add a field 'superior' of type 'List of Users'
1.2) Modify 'Custom Display' of field 'superior' as following:
  {{velocity}}
 {{html clean=false}}
 $value.get('first_name') $value.get('first_name')
  {{/velocity}}}
2) Modify the Selected Columns list for 'User Directory':
   first_name last_name superior
 
With the code above in 1.2, in the User Directory Panel my column 'superior'
is always
$value.get('first_name') $value.get('first_name')}

When I use in 1.2:
{{velocity}}
   $value
{{/velocity}}
I get at least the following output (when superior is 'hkraut')
XWiki.hkraut

Please can somebody tell me, if already point 1.1 was the wrong approach?
Or how can I adapt 1.2 to display the superior properly?
 
Many thanks,
Hubert



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Display-List-of-Users-Type-in-User-Directory-tp7594876.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users