Hide Pages in Navigation Tree

I have a wiki in this style:

  • page a
    • page aa
      • page aaa
      • page aab
      • page aac
      • page aad
    • page ab
  • page b

and so on. Now I want to hide all pages below “page aa”. Because the count of pages exceeds the count of listed pages and it’s not necessary to confuse people with the pages.
Is there a solution to hide all pages from navigation and not to exclude them from search index? So it’s a clean navigation tree only with the necessary pages?

Hi, have you looked at the exclusions parameter of the Document Tree macro https://extensions.xwiki.org/xwiki/bin/view/Extension/Document%20Tree%20Macro#HParameters

This is the macro used in the Navigation Panel (that you can edit). See https://extensions.xwiki.org/xwiki/bin/view/Extension/Panels%20Application

I had seen that. But is it a good idea to change the default pages of the wiki due to updates?

And “excludes” need a list of excluded Pages. I want to exclude all subpages of a page. That’s seems not so simple. Only to first select all subpages and then exclude them from the tree.

You have 2 choices here:

  1. Update the default Navigation Panel and when you upgrade XWiki, XWiki will perform a merge between your changes and any changes that could also have been brought to that panel’s page. See https://extensions.xwiki.org/xwiki/bin/view/Extension/Extension%20Manager%20Application#HUpgrade
  2. Create your own panel (by copying the default Nav panel for ex), and configure the panel list to use your panel.

From what I see in the doc examples, you can specify a whole wiki or a document. I’m pretty sure that you could specify a space too, using space:Space1.Space2...SpaceN. I’ve never tried it though.

I changed the own Navigationtree with following code:

## Exclude all pages below tag "hideSubpages"
#set($hiddenSubpages = $services.query.xwql("from doc.object(XWiki.TagClass) as tag where 'hideSubpages' member of tag.tags").execute())
#foreach($hiddenSubpage in $hiddenSubpages)
  #set ($hiddenSubpageWildCard = $hiddenSubpage.replaceAll(".WebHome$", ".%"))
  #set($children = $services.query.xwql("where doc.fullName like :name").bindValue("name", $hiddenSubpageWildCard).execute())
  #foreach($child in $children)
    #if($child != $hiddenSubpage)
      #set ($discard = $exclusions.add("document:" + $child))
    #end
  #end
#end

And it works, but I have pages with a “,” in the Name. The following line of the original code:

#set ($exclusions = $stringtool.join($exclusions, ','))

And the page is not excluded. I tried to escape the page Name with “%2C” but it don’t works. How do I escape Page names?

I think you’re referring to page references. You can try to use the escape character (\), but I hope that the document tree macro supports that (not sure). If it doesn’t work, then I’d say it’s a bug and you could report an issue in Loading...

Yes, I tried:

#set ($discard = $exclusions.add("document:" + $child.replaceAll(",", "\\,"))))

And it won’t work.

Bug report: Log in - XWiki.org JIRA