Page specific Navigation Panel

Hello everybody,

we’d like to do something similar to the XWiki Documentation Wiki. When going to the User Guide, you’ll find the user guide specific pages in the navigation panel:

When you go to the admin guide instead, the navigation panel shows pages from the admin guide.

Basically I need the navigation panel with a different root element. Is that something possible with the built-in tools?

After playing around with it for quite some time, I realized this is possible using a custom panel and velocity templates. I made my way from using one panel per “area”, then worked my way towards a definition that works for all top level sites, rendering the child pages dynamically, from the top level page downwards.

Velocity Code can probably be optimized, but works for me:

{{velocity}}
## Calculate root page as root for the documentTree Macro
#set ( $pageReference = $doc.pageReference.toString() )
#set ($pageIndex = $pageReference.indexOf('/', 16))

## If no index was found (probably a root page), use entire reference
#if ( !$pageIndex or $pageIndex == -1 )
#set ( $pageIndex = $pageReference.length())
#end

## Extract Root Page
#set ($rootPage = $pageReference.substring(0, $pageIndex).replaceAll("/", "."))

#navigationPanelHeader("Seitenübersicht")
## Escape special characters in macro parameter values.
{{documentTree showTranslations="false" showAttachments="false" showRoot="true" compact="true" root="document:${rootPage}.WebHome" openTo="document:${doc.documentReference}" /}}
#panelfooter()
{{/velocity}}