[Ricardo Rodriguez] eBioTIC. wrote:
> Hi!
> 
> Caleb James DeLisle wrote:
>> There are various ways with different levels of code cleanliness
>> since all user names start off with 'XWiki.' you could use 
>> $context.getUser().substring(6)
>>
>> If you're looking for the user's "common name" instead of the user name, you 
>> might want to look at
>> $xwiki.getUserName
>> http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xwiki/api/XWiki.html#getUserName%28java.lang.String%29
>>
>>   
> Please, as $context is a class and getUser() is a method of that class, 
> what is .substring()?

Another way of writing is:
#set($nameString = $xcontext.getUser())
#set($nameStringWithNoPrefix = $nameString.substring(6))
substring is a function of java.lang.String which is what's returned by 
context.getUser()
You can google java.lang.String to get a listing of all of String's functions.

> 
> Let's call *name* to the answer to the previous question. Please, where 
> are the possible *name* that could be used with a given method of a 
> given class?
> 
> I'm browsing XWiki API looking for a way of doing the same you have 
> proposed with .getUser() but with the name of a document. That is, how 
> to get Document instead Space.Document.
> 
> For instance, here...
> 
> #set($results=$xwiki.searchDocuments($query))
> #foreach($item in $results)
> #set ($itemdoc = $xwiki.getDocument($item))
> * [$itemdoc>$itemdoc],  ~~$itemdoc.display('Genrus') 
> $itemdoc.display('Species')~~<br/>
> 
> $itemdoc shows Space.Document. How do I get just Document?
> 
> Please, excuse me if this questions are too basic! Thanks for your help!
> 

If you just put the name of the document ie:
* [$itemdoc]
It should extract the user friendly name and display it automatically.

BTW: That is syntax/1.0 and all new development on the rendering engine is for 
the syntax/2.0
renderer. 1.0 will not be removed for quite some time but if you want to take 
advantage of new
features, I recommend writing new code in syntax/2.0.

Caleb

_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to