Changes for page Rangee Index

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

From version 17.1
edited by Tobias Wintrich
on 2025/10/14 16:36
Change comment: There is no comment for this version
To version 9.13
edited by Tobias Wintrich
on 2021/09/27 21:03
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,39 +1,42 @@
1 -{{python}}
2 -from xwiki import XWikiContextProvider
1 +{{tree links="true" icons="false" edges="false"}}
2 +{{velocity}}
3 +{{html wiki=true}}
4 +#set($query="where doc.fullName='Handbücher.10\.00.Admin Guide 10\.00.WebHome'")
5 + #set($results = false)
6 + #set($results = $xwiki.searchDocuments($query, 10, 0))
7 + #foreach($docname in $results)
8 + [[$xwiki.getDocument($docname).getTranslatedDocument()]]
9 + hu
10 + #end
3 3  
4 -xcontext = XWikiContextProvider().get()
5 -xwiki = xcontext.getWiki()
6 -services = xcontext.services
7 -doc = xcontext.doc
8 -wikimacro = locals().get('wikimacro', None)
9 -depth = 0
10 -if wikimacro and wikimacro.parameters.get("depth"):
11 - depth = int(wikimacro.parameters.get("depth"))
12 -
13 -# Sprache bestimmen
14 -if str(xcontext.locale) == 'de':
15 - locale = ''
16 -else:
17 - locale = str(xcontext.locale)
18 -
19 -def get_children(parent_fullname):
20 - query = services.query.xwql("where doc.parent = :doc and doc.hidden = 0 order by doc.title asc")
21 - return query.bindValue("doc", parent_fullname).addFilter("currentlanguage").execute()
22 -
23 -def render_tree(parent_fullname, current_depth):
24 - html = "<ul>"
25 - for child_name in get_children(parent_fullname):
26 - rdoc = xwiki.getDocument(child_name).getTranslatedDocument()
27 - if locale == rdoc.getLanguage():
28 - li_class = ""
29 - if current_depth > 0:
30 - li_class = "jstree-open"
31 - html += '<li class="' + li_class + '">[[{0}>>{1}]]</li>'.format(rdoc.getDisplayTitle(), rdoc.fullName)
32 - if current_depth < depth:
33 - html += render_tree(rdoc.fullName, current_depth + 1)
34 - html += "</ul>"
35 - return html
36 -
37 -print(render_tree(doc.fullName, 0))
38 -{{/python}}
39 -
12 +<ul>
13 +#foreach ($child in $doc.getChildrenReferences())
14 + <li class="jstree-open">
15 + [[$child]]
16 + <ul>
17 + #foreach ($subchild in $xwiki.getDocument($child).getChildrenReferences())
18 + <li class="jstree-open">
19 + [[$subchild]]
20 + <ul>
21 + #foreach ($subsubchild in $xwiki.getDocument($subchild).getChildrenReferences())
22 + <li class="jstree-open">
23 + [[$subsubchild]]
24 + <ul>
25 + #foreach ($subsubsubchild in $xwiki.getDocument($subsubchild).getChildrenReferences())
26 + <li class="jstree-open">
27 + [[$subsubsubchild]]
28 + </li>
29 + #end
30 + </ul>
31 + </li>
32 + #end
33 + </ul>
34 + </li>
35 + #end
36 + </ul>
37 + </li>
38 +#end
39 +</ul>
40 +{{/html}}
41 +{{/velocity}}
42 +{{/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