Request Structured Documents Macro
Last modified by Andreea Popescu on 2021/03/17 21:50
Allows you to easily list all the documents containing an object of a given class. |
Type | Doc (Velocity Macro) |
Category | |
Developed by | xwiki:XWiki.ThomasEveilleau |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Allows you to easily list all the documents containing an object of a given class (without having to write the HQL request) - ordered by creation date desc.
Usage
#requestdocuments("Class FullName" "Template FullName" )
Parameters definition
Name | Optional | Allowed values | Default value | Description |
---|---|---|---|---|
Class FullName | no | Space.Page | none | FullName of the page containing the Class |
Template FullName | yes | Space.Page | none | FullName of the Template page (for an exclusion) |
Example
#requestdocuments("XWiki.XWikiUsers" "")
#foreach ($results in $result)
* $results
#end
#foreach ($results in $result)
* $results
#end
Result
Installation
This a Velocity macro. Since it's not bundled by default you'll have to copy/paste the following code to use it:
#macro(requestdocuments $class $template)
#if($template!="")
#set($exclude = "and doc.fullName!='${template}'")
#else
#set($exclude = "")
#end
#set ($request = ", BaseObject as obj where doc.fullName=obj.name and obj.className='${class}' $exclude order by doc.creationDate desc")
#set($result=$xwiki.searchDocuments($request))
#end
#if($template!="")
#set($exclude = "and doc.fullName!='${template}'")
#else
#set($exclude = "")
#end
#set ($request = ", BaseObject as obj where doc.fullName=obj.name and obj.className='${class}' $exclude order by doc.creationDate desc")
#set($result=$xwiki.searchDocuments($request))
#end