Tree Navigation

Last modified by Alex Cotiugă on 2021/03/18 11:28

cogModified Navigation Panel which implements a Tree View of the selected space
TypeSnippet
Category
Developed by

xwiki:XWiki.sono

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

A new Document Tree Macro has been introduced in XWiki 6.3. In addition the Navigation Panel has been overhauled to use that macro too.

Name: TreeNav

Panel type: view

Category: Navigation

Description:
 We would have loved to display a Tree View of each space, but the DocumentTree plugin has severe shortcomings (bugs). Therefore we switch spaces every time we want to display the contents of a different space, to work around those bugs.

Note: Blacklisting NI.

Code

#set ($MAXDEPTH = 5)
#panelhiddenheader("Navigation")
#set ($hiddenSpaces = ["XWiki", "Admin", "Panels"])
#set ($hiddenPages = ["Main.WebRss", "Main.WebSearch", "Main.LuceneSearch", "Main.WebSearchRss", "Main.BlogRss", "Blog.Macros", "Main.TagsRss", "Main.RegisterNewUserAction", "Main.SpaceIndex", "Blog.Category"])
#set ($blackListedPages = ["WebPreferences"])
<div id="xwikinavcontainer">
#set($spaces = $xwiki.spaces)
#set($i = 0)
#set($spacecount = 0)
<div id="xwikinav">
#foreach($space in $spaces)
#if (!$hiddenSpaces.contains($space) || ($hiddenSpaces.contains($space) && $xwiki.hasAdminRights()))
#if ($doc.web == $space)
#set ($spacecount = $i)
#end
#set($i = $i + 1)
#set($spaceWebHome = $space + "." + "WebHome")
<div class="accordionTabTitleBar"><h6>[$space>$spaceWebHome]</h6></div>
#if ($doc.web == $space)
<div class="accordionTabContentBox">
#set($tree = $xwiki.doctree.getSpaceDocumentTree($space,false))
#set($depths=["", "-", "--", "---", "----", "-----", "------", "-------", "--------"])
#foreach($leaf in $tree)
#set($leafName = $leaf.fullName)
#set($dotIndex = $leafName.indexOf(".")+1)
#set($pageName = $leafName.substring($dotIndex, $leafName.length()))
#set($pageLink = $space + "." + $pageName)
#if($leaf.depth > 0 && $leaf.depth < $MAXDEPTH)
$depths.get($leaf.depth) [$xwiki.getDocument($pageLink).getDisplayTitle()>$pageLink]
#end
#end
</div>
#end
#end
#end
</div>
</div>
#panelfooter()
Tags: panel
     

Get Connected