Transformation into XWiki macro went with ease :)
A lot less code in the pages now.

I did an enhancement on the actual snippet itself, now it's capable of
accepting comma-separated lists of log-ins, transforming them into
comma-separated list of [full-user-name-link-to-user-page].

{{velocity}}
#macro(displayFullNameByLogin $logins)
  ## split incoming string by zero-or-more number of
  ##   ’ ’ (space), ’\t’ (tab) and ’,’ (comma) 
  ## symbols. This way there will be less empty elements in the resulting
array
  ## Useful links:
  ##  http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting#HBindings
  ## 
http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/XWikiContext.html
  ## 
http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/util/Util.html
  #set($userLoginsArray = $xcontext.util.split(’/[,| |\t]+/’, $logins))
{{html}}
  #foreach( $login in $userLoginsArray )
      #if ("$!login" == "" )
        ## ignore null or empty (see
http://wiki.apache.org/velocity/CheckingForNull)
      #else
        #set($userDocName = "XWiki."+$login)
        ## check for last iteration before appending ",&nbsp"
        ## http://velocity.apache.org/engine/devel/user-guide.html#Loops
        $xwiki.getUserName($userDocName, true)#if( $velocityHasNext
), #end
      #end 
  #end
{{/html}}
#end
{{/velocity}}

Thanks for the hints! :)

-- 
View this message in context: 
http://n2.nabble.com/Code-snippet-Full-user-name-and-link-by-log-in-tp4838148p4843182.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to