Create a navbar for a specific section only

Hello, we are using xwiki 12.10.7. At the moment, the navigation bar displays all the sections that we have. I made a separate page on which I want to list all the sections in our wiki (Screen 1). When clicking on a link to a separate section, I want to navigate only through the pages of this section. At the moment, if I go, for example, to the section - Archive of statistical data, then all sections of are displayed in the navigation panel (Screen 2). Please tell me if it is possible to make such a navigation panel so that only pages of the current section are displayed in it - Archive of statistical data (Screen 3)?Screen 1
Screen 2
Screen 3

The nav panel is used to navigate in the full wiki normally. If you need in-page nav we usually add a TOC macro in the page.

For example: https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/PageEditing

Would that satisfy your need?

Now, you could create a new panel to display only the nav for the current page too. You can also edit the existing nav panel but then you won’t be able to navigate to other pages with it.

To edit the nav panel, see https://extensions.xwiki.org/xwiki/bin/view/Extension/Panels%20Application#HNavigationPanel and you can list all panels in your wiki and edit them at https://extensions.xwiki.org/xwiki/bin/view/Extension/Panels%20Application#HAccesstothePanelslist

Hello, thank you for your answer.

The toc macro is not suitable for us, since it displays only the structure of the current page, and what we need is navigation through the child (nested) pages.

We would not like to change the navigation bar as its functionality may be useful.

You wrote that we can create a new panel in which there will be navigation through the child pages of some particular page. When creating a panel, you need to write code, please tell me, maybe you already have a ready-made solution or maybe there is some kind of extension that allows you to navigate through the child pages of a separate section?

Hello,

I recently was working on the same problem and solved it. However please note that this solution might be inefficient and looks ugly and complicated, since I limited myself to Velocity because of reasons, which only offers foreach-loops to work with.

Copy this code right after the first line that you see in my code in the Navigation Panel if you want to test it out.

#set ($exclusions = $stringtool.join($exclusions, ','))
##
##Implements the concept of the Confluence-Space on the Navigation Bar
#set($openToD = $services.model.serialize($doc.documentReference, 'default'))
##Exclude '.' that are in the name of the document
#set ($openToD = $openToD.replaceAll('(\\.)', ''))
#set($openLength = $openToD.length())
##Count the '.' in the reference of the doc the user is in
#set($counter = 0)
#set($start = 1)
#set($end = $openLength)
#set($range = [$start..$end])
#foreach($i in $range)
   #if($i < $end && $openToD.substring($i, $i + 1).equals("."))
     #set($counter = $counter + 1)
   #end
#end

##If User is in Home, Display the normal Nav. Panel
#if ($doc == 'Main.WebHome')

  {{documentTree showTranslations="false" showAttachments="false" compact="true" openTo="document:$openToDoc"
  limit="9999" exclusions="$exclusions" /}}
#else
##Getting the Reference of the "Space" - As in the Confluence-Space
#set($parentPageReferenceSerialized = $doc.documentReference)
#set($start1 = 1)
#set($end1 = $counter)
#set($range1 = [$start1..$end1])
#set($parentPageReference = $doc.documentReference)
#foreach($i in $range1)
   ##Get the Parent Page references, up to the Space reference
   #set($parentPageReference = $parentPageReference.parent)
   #set($parentPageReferenceSerialized = $services.model.serialize($parentPageReference, 'default'))
#end
#set($parentPageReferenceSerialized = $parentPageReferenceSerialized + ".WebHome")

{{documentTree root="document:$parentPageReferenceSerialized" openTo="document:$openToDoc" showRoot="true" showWikis="true" showAttachments="false" compact="true"/
  limit="9999" exclusions="$exclusions" /}}

#end
#panelfooter()
{{/velocity}}

I took the time to optimize this again and put it in groovy (put this groovy script before the velocity script).

{{groovy}}
def counter = 0;
def openToDoc = doc.documentReference.toString().replaceAll(/([~"])/, '~$1')
xcontext.put("openToDoc",openToDoc)
def openToD = openToDoc.replaceAll('(\\\\\\.)', '')
def openLength = openToD.length();
for (int i = 0; i < openLength; i++) {
  if (openToD.charAt(i) == '.') {
    counter = counter + 1;
  }
}
def parentPageReference = doc.documentReference;
for(int i=0; i < counter; i++) {
  parentPageReference = parentPageReference.parent;
}
def parentPageReferenceSerialized = services.model.serialize(parentPageReference, 'default');
parentPageReferenceSerialized = parentPageReferenceSerialized + ".WebHome"
xcontext.put("parentPageReferenceSerialized",parentPageReferenceSerialized);
{{/groovy}}

Then put the following in the velocity script:

##Implements the Confluence-Space:
##If User is in Home, Display the normal Nav. Panel
#if ($doc == 'Main.WebHome')

  {{documentTree showTranslations="false" showAttachments="false" compact="true" openTo="document:$openToDoc"
  limit="9999" exclusions="$exclusions" /}}
#else
##Getting the Reference of the "Space" - As in the Confluence-Space
#set($parentPageReferenceSerialized = $xcontext.get("parentPageReferenceSerialized"))

{{documentTree root="document:$parentPageReferenceSerialized" openTo="document:$openToDoc" showRoot="true" showAttachments="false" compact="true"/
  limit="9999" exclusions="$exclusions" /}}

#end
#panelfooter()