page_whiteLists all documents in a certain space
TypeSnippet
Category
Developed by

Paul Libbrecht, Vincent Massol

Rating
0 Votes
LicenseGNU 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}}

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')

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.

Tags: querying
     

Get Connected