Hello,
im currently trying to build an “as basic as it gets” version of the documentTree macro in velocity that creates an simple bullet list with XWiki links so that I can use this in the Navigation Menu bar.
Im quite successfull, howerver there is one thing I absolutely don’t understand: The current page that where the macro is run from is always listed as a children, even when it is definetly not a children from the reference?!
Here is my code, it is running as velocity script in my current page “Testarea.WebHome”
{{velocity}}
#set($parentReference = $services.model.createDocumentReference('', 'MyTopPageIWantToListInTheNavigationMenu', ''))
#set($objClass = $itemDocument.getObject('XWiki.RedirectClass'))
#set($parentDocument = $xwiki.getDocument($parentReference))
(% id="clientList" class="doOddEven filterable grid sortable" %)
(% class="sortHeader" %)
#foreach ($child in $sorttool.sort($parentDocument.getChildren()))
#set ($childDoc = $xwiki.getDocument($child))
#set ($childDocTitle = $childDoc.plainTitle)
## #if ($xwiki.hasAccessLevel('view', $services.user.currentUserReference , "$childDoc.WebHome") == true && !$objClass)
#if ($childDoc)
* [[${childDocTitle}>>doc:${child}]]
#foreach ($SUBchild in $sorttool.sort($childDoc.getChildren()))
#set ($SUBchildDoc = $xwiki.getDocument($SUBchild))
#set ($SUBchildDocTitle = $SUBchildDoc.plainTitle)
## #if ($xwiki.hasAccessLevel('view', $services.user.currentUserReference , "$SUBchildDoc.WebHome") == true && !$objClass)
#if ($SUBchildDoc)
** [[${SUBchildDocTitle}>>doc:${SUBchild}]]
#end
#end
#end
#end
{{/velocity}}
Now this script lists everything correctly as I want. BUT the first ever entry, is always the Testarea itself ?!
Im completely confused and appreciate any help.
Best regards,
Tom
Also has anybody an more easy way? Maybe to get the documentTree to be simply create an bullet list with links so that it can be used in the Navigation Menu of the Menu Application?