I use this macro for that topic
{{velocity}}
#macro(createDocumentTree $document $depth $level)
#if ($depth > 0)
#set ($translated = $document.getTranslatedDocument())
#set ($name = $translated.getName())
#set ($fullName = $translated.getFullName())
#set ($prefixedFullName = $translated.getPrefixedFullName())
#set ($where = "where doc.parent = ? or doc.parent = ? or doc.parent = ?
order by doc.name")
#set ($parameters = [$name, $fullName, $prefixedFullName])
#if ($name == 'WebHome')
#set ($space = $document.getSpace())
#set ($where = "where doc.space = ? and (doc.parent = '' or doc.parent =
? or doc.parent = ? or doc.parent = ?) and doc.name != 'WebHome' order by
doc.name")
#set ($parameters = [$space, $name, $fullName, $prefixedFullName])
#end
#foreach ($name in $xwiki.searchDocuments($where, $parameters))
#if ($xwiki.getDocument($name))
#set ($document = $xwiki.getDocument($name))
#set ($translated = $document.getTranslatedDocument())
#set ($prefixed = $translated.getPrefixedFullName())
#set ($title = $translated.getPlainTitle())
${stringtool.repeat('*', $level)} [[$title>>$prefixed]]
#set ($depth = $depth - 1)
#set ($level = $level + 1)
#createDocumentTree($document $depth $level)
#set ($depth = $depth + 1)
#set ($level = $level - 1)
#end
#end
#end
#end
#createDocumentTree($doc 5 1)
{{/velocity}}
--
View this message in context:
http://xwiki.475771.n2.nabble.com/How-can-I-display-a-subtree-with-hierarch…
Sent from the XWiki- Users mailing list archive at
Nabble.com.