Playing Peek-a-Boo: Hiding pages with the Navigation Manager

There might be several reasons for hiding pages in the navigation structure, but they have to be connected to the navigation list, to show the website’s navigation correctly:

  • „Footer pages“ like „Imprint“ or „Terms of use“
  • Pages for login, error handling (e.g. for 404 or 403 errors), search results
  • A new navigation branch (e.g. a new product group, new features of your website)

For those pages, you can set a flag in the Navigation Manager called „Reference to parent level“. You can now set up your render-spot to hide these flagged pages. However, this method has two major disadvantages:

  • These pages won’t be published if you select your web project’s root node and publish all pages with following pages. You have to publish every single flagged page by hand.
  • It’s complicated to hide a whole page tree: You have to flag all sub pages of the node you want to hide first, before you can flag the node itself, which makes it very inconvenient to apply this method to nested navigation structures.

Furthermore, you need to have navigation manager rights to hide pages (this can be seen as both advantage and disadvantage).

Before you start fiddling around, fighting your way though your navigation structure to hide some pages, there is another method, which is far more convenient:

Include an option list in each of your Masterpages called „opt_show_in_navigation“ with two values: „show“ and „hide“.

Around your existing navigation templates, use this code:

XML:
  1. <reddot:cms>
  2.   <if>
  3.     <query valuea="Context:CurrentPage.Elements.GetElement(opt_show_in_navigation).GetHtml()" operator="!=" valueb="String:hide">
  4.       ... your navigation code goes here ...
  5.     </query>
  6.   </if>
  7. </reddot:cms>

This will only display the current page in your navigation if the option list is not explicitly set to „hide“, as option lists may be set to an empty value.

Voilá, the page and all of its sub pages are hidden from your navigation! To access it in SmartEdit, you have to use the search function. Of cause, this statement can be altered to hide pages only during publishing while having all pages visible in SmartEdit:

XML:
  1. <reddot:cms>
  2.   <if>
  3.     <query valuea="Context:CurrentRenderMode" operator="==" valueb="Int:2">
  4.     <if>
  5.       <query valuea="Context:CurrentPage.Elements.GetElement(opt_show_in_navigation).GetHtml()" operator="!=" valueb="String:hide">
  6.         ... show navigation ...
  7.       </query>
  8.     </if>
  9.   </query>
  10.   <query type="else">
  11.     ... show navigation ...
  12.   </query>
  13. </if>
  14. </reddot:cms>

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.5 out of 5)
Loading ... Loading ...

7 Reaktionen zu “Playing Peek-a-Boo: Hiding pages with the Navigation Manager”

  1. James

    Can you show the code of your option list?

  2. Markus Giesen

    Just use a normal option list element and fill it with two differnet values:
    1: hide
    2: show

    Set the default value to “show”

  3. tootie

    Question -
    When I implement this I do not get the desired results. Instead it is hiding all my navigation instead of the page.

    What exactly do you have in the section that says ….show navigation….?
    I am using:

    I understand why it’s hiding the whole navigation, what I don’t get is how you target a page within rendered navigation.

  4. tootie

    Something weird just happened to my html - let me try this again!

    htmltext
    %!! Navigation:OutputArea(KB Level 4 Left Menu) !!%
    /htmltext

  5. tootie

    nevermind - i missed the “navigation template” part that you wrote! I’ll try to be less klunky today! Thank you for all your good contributions.

  6. sam

    This will hide page and it’s subpages BUT what about if this page is a child page. How do I hide the page from the navigation on it’s parents page?

  7. Markus Giesen

    Should work for both cases, just play with the code within your Navigation Manager templates