Changes for page Rangee Index
Last modified by Tobias Wintrich on 2025/10/31 08:26
From version 9.15
edited by Tobias Wintrich
on 2021/09/27 21:04
on 2021/09/27 21:04
Change comment:
There is no comment for this version
To version 16.1
edited by Tobias Wintrich
on 2025/10/14 16:35
on 2025/10/14 16:35
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,14 +1,33 @@ 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 - huhuhuhuhuh 10 - #end 1 +{{python}} 2 +from xwiki import XWikiContextProvider 11 11 12 -{{/html}} 13 -{{/velocity}} 14 -{{/tree}} 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 +
- 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