Changes for page Rangee Index
Last modified by Tobias Wintrich on 2025/10/31 08:26
From version 9.1
edited by Tobias Wintrich
on 2021/09/27 14:58
on 2021/09/27 14:58
Change comment:
There is no comment for this version
To version 20.3
edited by Tobias Wintrich
on 2025/10/15 08:13
on 2025/10/15 08:13
Change comment:
There is no comment for this version
Summary
-
Objects (1 modified, 1 added, 0 removed)
Details
- XWiki.WikiMacroClass[0]
-
- Context elements
-
... ... @@ -1,0 +1,1 @@ 1 +Sprache - Macro code
-
... ... @@ -1,34 +2,54 @@ 1 -{{tree links="true"}} 2 2 {{velocity}} 3 -{{html wiki=true}} 4 -<ul> 5 -#foreach ($child in $doc.getChildren()) 6 - <li class="jstree-open"> 7 - [[$child]] 8 - <ul> 9 - #foreach ($subchild in $xwiki.getDocument($child).getChildren()) 10 - <li class="jstree-open"> 11 - [[$subchild]] 2 +{{tree links="true" edges="false"}} 3 +#set($depth = $wikimacro.parameters.depth) 4 + 5 +## Locale bestimmen 6 +#set($locale = '') 7 +#if ($xcontext.locale != 'de') 8 + #set($locale = $xcontext.locale) 9 +#end 10 + 11 +## Macro für rekursive Baumstruktur 12 +#macro(renderTreeNode $docFullName $currentDepth) 13 + #set($doc = $xwiki.getDocument($docFullName)) 14 + #set($translatedDoc = $doc.getTranslatedDocument()) 15 + 16 + ## Nur rendern wenn Sprache passt 17 + #if ($locale == $translatedDoc.getLanguage()) 18 + #set($cssClass = '') 19 + #if ($currentDepth < $depth) 20 + #set($cssClass = 'jstree-open') 21 + #end 22 + <li class="$cssClass"> 23 + [[$translatedDoc.getDisplayTitle()>>$translatedDoc.fullName]] 24 + 25 + ## Kinder-Dokumente abfragen 26 + #set($childQuery = $services.query.xwql('where doc.parent = :parentDoc and doc.hidden = 0 order by doc.title asc')) 27 + #set($children = $childQuery.bindValue('parentDoc', $docFullName).addFilter('currentlanguage').execute()) 28 + 29 + ## Rekursiv rendern wenn Kinder vorhanden sind 30 + #if ($children && $children.size() > 0 && $currentDepth < $depth) 31 + #set($nextDepth = $currentDepth + 1) 12 12 <ul> 13 - #foreach ($subsubchild in $xwiki.getDocument($subchild).getChildren()) 14 - <li class="jstree-open"> 15 - [[$subsubchild]] 16 - <ul> 17 - #foreach ($subsubsubchild in $xwiki.getDocument($subsubchild).getChildren()) 18 - <li class="jstree-open"> 19 - [[$subsubsubchild]] 20 - </li> 21 - #end 22 - </ul> 23 - </li> 24 - #end 33 + #foreach($childDocName in $children) 34 + #renderTreeNode($childDocName $nextDepth) 35 + #end 25 25 </ul> 26 - </li> 27 - #end 28 - </ul> 29 - </li> 37 + #end 38 + </li> 39 + #end 30 30 #end 41 + 42 +{{html wiki=true}} 43 +<ul> 44 + ## Root-Dokumente laden 45 + #set($rootQuery = $services.query.xwql('where doc.parent = :doc and doc.hidden = 0 order by doc.title asc')) 46 + #set($rootDocs = $rootQuery.bindValue('doc', $doc.fullName).addFilter('currentlanguage').execute()) 47 + 48 + #foreach($docName in $rootDocs) 49 + #renderTreeNode($docName 1) 50 + #end 31 31 </ul> 32 32 {{/html}} 33 -{{/velocity}} 34 34 {{/tree}} 54 +{{/velocity}}
- XWiki.WikiMacroParameterClass[0]
-
- Parameter default value
-
... ... @@ -1,0 +1,1 @@ 1 +5 - Parameter description
-
... ... @@ -1,0 +1,1 @@ 1 +Öffne bis Ebene (0-5) - Parameter mandatory
-
... ... @@ -1,0 +1,1 @@ 1 +No - Parameter name
-
... ... @@ -1,0 +1,1 @@ 1 +depth