SilverStripe CMS module for nested SiteTree menus
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Nested Menu Module


A SilverStripe module which adds template functions for a nested SiteTree menu.

The module will add the methods NestedMenu and HasNestedMenu to the SiteTree class via extension and and makes those methods available in the templates.

This decorator also adds a checkbox field (ShowChildrenInMenus) to the CMS admin interface to allow CMS users to hide all of the sub-pages of a page from the nested menu.

Screenshots (Basic!)

Example of basic NestedMenu


  • SilverStripe 2.4


  • Put the module into your SilverStripe installation
  • Add the additional field by visiting http://<yoursite>/dev/build


Add menu to template

In your template:


Which will output HTML in the form:

<ul class="nested-menu nested-menu-level-1 nested-menu-nesting-1">
  <li class="first link"><a class="first link" href="/">Home</a></li>
  <li class="current open"><a class="current open" href="/about-us/">About Us</a>
    <ul class="nested-menu-level-2 nested-menu-nesting-2"><li class="first link">
      <li class="first link"><a class="first link" href="/about-us/our-staff/">Our Staff</a></li>
      <li class="last link"><a class="last link" href="/about-us/another-page/">Another Page</a></li>
  <li class="last link"><a class="last link" href="/contact-us/">Contact Us</a></li>

The HTML puts classes on both the list item and the anchor to aid styling. The nested-menu class will always be put on ONLY the outer ul

You can also start at a sub level (good for when you have a horizontal top-level nav) by calling NestedMenu with a parameter indicating the level to start at:


You can limit the maximum depth of the nesting by specifying a second parameter:


You can also use HasNestedMenu to include additional markup if a menu is available, e.g:

<% if HasNestedMenu(2) %>
  <nav id="secondary-navigation">
    <h4>In this section&hellip;</h4>
<% end_if %>

Style with CSS

No CSS is currently included in this module.