Velocity : retrieving language, other language translations, last updting date of docs

Hi,

I started writing a velocity macro in a wiki to list in a table all pages (docs) containing a certain object. It works.
Now I would like :
To retrieve the language of the doc.
To retrieve the last updating date of the doc
To retrieve the other existing translations

Could I get a hint for the queries concerning these different properties?

{{velocity}}
$xwiki.jsfx.use("js/xwiki/table/tablefilterNsort.js", true)
$xwiki.ssfx.use("js/xwiki/table/table.css")
{{html wiki="true"}}

#set($hql = "select distinct doc from XWikiDocument as doc, BaseObject as obj where obj.name=doc.fullName and obj.className='Documentation.Code.SectionClass' order by doc.title asc")
#set($resulos = $xwiki.search($hql, 500, 0))
<table id="fred" class="grid sortable" style="width: 85%;">
<tr class="sortHeader">
<th style="width: 85%;">Title</th><th style="width: 15%;"></th>
</tr>

#foreach ($itemo in $results)
#set ($label = $itemo.getTitle())
<tr><td>[[$label>>$itemo]]</td><td align=right</td></tr>
#end

</table>
{{/velocity}}

I think it would be even nicer if you were using the livedata macro: https://extensions.xwiki.org/xwiki/bin/view/Extension/Live%20Data%20Macro/

That would scale better, allow filtering, sorting, different views, etc :slight_smile:

And it supports xobjects.

For example to list all pages with the XWiki.XWikiUsers xobject:

{{liveData
  id="users"
  properties="_avatar,doc.name,first_name,last_name"
  source="liveTable"
  sourceParameters="className=XWiki.XWikiUsers&translationPrefix=xe.userdirectory."
/}}
2 Likes

$doc.getLocale()

1 Like

And if you want that in the query you can filter on the language column, see xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/xwiki.hbm.xml at 405d210dfad79f723617ba727fbcc5f0f6d2fbca · xwiki/xwiki-platform · GitHub

1 Like

Thanks!