Changes for page Rangee Index

Last modified by Tobias Wintrich on 2025/10/31 08:26

From version 16.1
edited by Tobias Wintrich
on 2025/10/14 16:35
Change comment: There is no comment for this version
To version 9.2
edited by Tobias Wintrich
on 2021/09/27 14:59
Change comment: There is no comment for this version

Summary

Details

XWiki.WikiMacroClass[0]
Context elements
... ... @@ -1,1 +1,0 @@
1 -Sprache
Macro code
... ... @@ -1,33 +1,34 @@
1 -{{python}}
2 -from xwiki import XWikiContextProvider
3 -
4 -# Kontext-Objekte
5 -xcontext = XWikiContextProvider().get()
6 -xwiki = xcontext.getWiki()
7 -services = xcontext.services
8 -doc = xcontext.doc
9 -depth = wikimacro.parameters.get("depth", 0)
10 -
11 -# Sprache setzen
12 -locale = "" if str(xcontext.locale) == "de" else str(xcontext.locale)
13 -
14 -def get_children(parent_fullname):
15 - query = services.query.xwql("where doc.parent = :doc and doc.hidden = 0 order by doc.title asc")
16 - return query.bindValue("doc", parent_fullname).addFilter("currentlanguage").execute()
17 -
18 -def render_tree(parent_fullname, current_depth):
19 - html = "<ul>"
20 - for child_name in get_children(parent_fullname):
21 - rdoc = xwiki.getDocument(child_name).getTranslatedDocument()
22 - if locale == rdoc.getLanguage():
23 - li_class = "jstree-open" if current_depth > 0 else ""
24 - html += f'<li class="{li_class}">[[{rdoc.getDisplayTitle()}>>{rdoc.fullName}]]</li>'
25 - if current_depth < depth:
26 - html += render_tree(rdoc.fullName, current_depth + 1)
27 - html += "</ul>"
28 - return html
29 -
30 -html_output = render_tree(doc.fullName, 0)
31 -print(html_output)
32 -{{/python}}
33 -
1 +{{tree links="true" icons="false"}}
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]]
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
25 + </ul>
26 + </li>
27 + #end
28 + </ul>
29 + </li>
30 +#end
31 +</ul>
32 +{{/html}}
33 +{{/velocity}}
34 +{{/tree}}
XWiki.WikiMacroParameterClass[0]
Parameter default value
... ... @@ -1,1 +1,0 @@
1 -5
Parameter description
... ... @@ -1,1 +1,0 @@
1 -Öffne bis Ebene (0-5)
Parameter mandatory
... ... @@ -1,1 +1,0 @@
1 -No
Parameter name
... ... @@ -1,1 +1,0 @@
1 -depth