Request Structured Documents Macro

Last modified by Andreea Popescu on 2021/03/17 21:50

cogAllows you to easily list all the documents containing an object of a given class.
TypeDoc (Velocity Macro)
Category
Developed by

xwiki:XWiki.ThomasEveilleau

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

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

NameOptionalAllowed valuesDefault valueDescription
Class FullNamenoSpace.PagenoneFullName of the page containing the Class
Template FullNameyesSpace.PagenoneFullName of the Template page (for an exclusion)

 

Example

#requestdocuments("XWiki.XWikiUsers" "")

#foreach ($results in $result)
* $results
#end

Result

requestresult.png

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
Tags:
    

Get Connected