2007/10/9, goldring, richard <richard.goldring(a)uk.thalesgroup.com>om>:
#set ($list = $xwiki.search("select doc.fullName
from XWikiDocument doc,
BaseObject obj, StringProperty prop where doc.fullName=obj.name and
obj.className='XWiki.ArticleClass' and prop.id.id=obj.id and
prop.name='title' and prop.value like 'Art%'", 5, 0))
Remember that you'll get only the 5 first results with this call :
http://build.xpertnet.biz/latestdoc/api/com/xpn/xwiki/api/XWiki.html#search…
from :
http://build.xpertnet.biz/latestdoc/api/com/xpn/xwiki/api/package-summary.h…
#foreach ($item in $list)
#set($bentrydoc = $xwiki.getDocument($item))
#set($class = $bentrydoc.getObject("XWiki.ArticleClass").xWikiClass)
$bentrydoc.name
<table border="1" cellspacing="0" cellpadding="2">
#foreach($prop in $class.properties)
<tr>
<td> *${prop.prettyName}* </td>
<td>Value: $doc.display($prop.value)</td> <--- this line!
</tr>
#end
</table>
While you know the type of the object you want to display you don't
have to use the xWikiClass (which is privileged API).
You can consult the list of the class properties at :
/xwiki/bin/edit/XWiki/ArticleClass?editor=class (class editor,
accessible from the top menu).
I'd refactor your snippet like this :
#foreach ($item in $list)
#set($bdoc = $xwiki.getDocument($item))
$bdoc.title
<table border="1" cellspacing="0" cellpadding="2">
<tr>
<td> *Title* </td>
<td>$bdoc.display("title")</td>
</tr>
<tr>
<td> *Category* </td>
<td>$bdoc.display("category")</td>
</tr>
<tr>
<td> *Content* </td>
<td>$bdoc.display("content")</td>
</tr>
</table>
#end
JV.