List All Documents In A Space
Last modified by Manuel Leduc on 2023/10/10 16:57
Lists all documents in a certain space |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
This example lists all documents in the Blog space:
{{velocity}}
#set($hql = "where doc.space='Blog' order by doc.date asc")
#set($results = $xwiki.searchDocuments($hql, 0, 0))
#foreach ($item in $results)
* $item
#end
{{/velocity}}
#set($hql = "where doc.space='Blog' order by doc.date asc")
#set($results = $xwiki.searchDocuments($hql, 0, 0))
#foreach ($item in $results)
* $item
#end
{{/velocity}}
See also the Velocity Examples.
That can also be used within an XWiki Class Property, e.g. to construct a field that chooses among the documents of a given space: Just say that this property is of type Database List and use the following for the query field:
select doc.name, doc.title
from com.xpn.xwiki.doc.XWikiDocument as doc
where doc.space = 'MySpace'
and doc.name!='WebHome')
from com.xpn.xwiki.doc.XWikiDocument as doc
where doc.space = 'MySpace'
and doc.name!='WebHome')
Editing a class-instance with the default display method doc.display('field-name') then brings a pop-up with the names of all documents of that space.