On Apr 1, 2010, at 6:49 PM, Thomas Mortagne wrote:

> You should share that kind of things on http://code.xwiki.org ;)

err wait I think it can improved first :)

> On Thu, Apr 1, 2010 at 18:21, coldserenity <[email protected]> wrote:
>> 
>> Sorry for spam, just can't resist sharing my first small victory in
>> programming XWiki :)
>> XWiki 2.0 Markup-based code-snippet for displaying user's full name with
>> link to profile by log-in.
>> 
>> {{velocity}}
>> #macro(displayFullNameByLogin $login)
>>    #set($userDocName = "XWiki."+$login)
>>    #set($userDoc = $xwiki.getDocument($userDocName))
>>    #if (!$userDoc)

This will probably not work since getDocument, contrary to its name, create a 
document if it doesn't exist... :)

$userDoc.isNew() would work.

There might be a better way to do this but I'll let others offer suggestions... 
There might even be an api to get what you wanted to do, in one line.

Thanks
-Vincent

>>        $login (does not exist)
>>    #else
>>        #set($userObject = $userDoc.getObject("XWiki.XWikiUsers"))
>>        #if(!$userObject)
>>          User Sheet
>>          This stylesheet must be applied on a document containing a
>> XWiki.XWikiUsers object.
>>        #else
>>          [[$xwiki.getUserName($userDoc.fullName,
>> false)>>$userDoc.fullName]]
>>        #end
>>    #end
>> #end
>> {{/velocity}}
>> 
>> Usage
>> {{velocity}}#displayFullNameByLogin("rmuntyan"){{/velocity}}
>> 
>> Regards,
>>  Roman
>> --
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to