Tree Nav Snippet

Name: TreeNav
Panel type: view
Category: Navigation
Description:
This is a modified Navigation Panel which implements a Tree View of the selected space. We would have loved to display a Tree View of each space, but the DocumentTree plugin has severe shortcomings (bugs). Therefore we switch spaces everytime 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()

Version 3.1 last modified by VincentMassol on 09/12/2007 at 15:30

Comments 0

No comments for this document

Attachments 0

No attachments for this document

Creator: sono on 2007/09/03 11:45
This wiki is licensed under a Creative Commons license
1.4.1.10194