Hi All,
i tested and tried and found a solution which gives my needed result. Now i
get the nested content of a space in nice order and with correct headings.
Looks a bit ugly, but works:
{{velocity}}
#macro(display $idoc)
#set($depth = $idoc.getSpace().toString().length() -
$idoc.getSpace().toString().replace(".", "").length() )
#if($depth==1)
##* $depth $idoc.getSpace()
= [[$idoc.getTitle()>>${idoc.getSpace()}.${idoc.getName()}]]=
#elseif($depth==2)
##** $depth $idoc.getSpace()
== [[$idoc.getTitle()>>${idoc.getSpace()}.${idoc.getName()}]]==
#elseif($depth==3)
##*** $depth $idoc.getSpace()
=== [[$idoc.getTitle()>>${idoc.getSpace()}.${idoc.getName()}]]===
#elseif($depth==4)
##**** $depth $idoc.getSpace()
==== [[$idoc.getTitle()>>${idoc.getSpace()}.${idoc.getName()}]]====
#elseif($depth==5)
##***** $depth $idoc.getSpace()
=====
[[$idoc.getTitle()>>${idoc.getSpace()}.${idoc.getName()}]]=====
#end
^^$idoc.getSpace(), Level: $depth^^
{{include document="${idoc.getSpace()}.${idoc.getName()}"
context="new"/}}
#getChildren($idoc)
#foreach ($i in $children)
#display($i)
#end
#end
#macro(getChildren $document)
#set($depthParent = $document.getSpace().toString().length() -
$document.getSpace().toString().replace(".", "").length() )
#set($children = [])
#set($q = "where doc.space like '%${document.getSpace()}.%' and not
doc.name='WebPreferences' and not doc.space='${document.getSpace()}'
order
by doc.title asc")
#set($r = $xwiki.searchDocuments($q, 0, 0))
#foreach ($i in $r)
#set( $idoc = $xwiki.getDocument($i))
#set($depthChild = $idoc.getSpace().toString().length() -
$idoc.getSpace().toString().replace(".", "").length() )
#if($depthChild == ($depthParent + 1))
#set($dummy = $children.add($idoc))
#end
#end
#end
#set($hql = "where doc.space like '%${doc.getSpace()}%' and not
doc.name='WebPreferences' and not doc.space='${doc.getSpace()}' order by
doc.title asc")
#set($chapters = $xwiki.searchDocuments($hql, 0, 0))
#foreach ($item in $chapters)
#set( $d = $xwiki.getDocument($item))
#if($d.getSpace().equals("${doc.getSpace()}.${d.getSpace().substring($mathtool.add($d.getSpace().lastIndexOf('.'),1),$d.getSpace().length())}"))
#display($d)
#end
#end
{{/velocity}}
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Set-Parent-in-XWiki-8-0-tp7598643p7598671…
Sent from the XWiki- Users mailing list archive at
Nabble.com.