Skip to content
effkay edited this page Oct 24, 2014 · 1 revision

Building a navigation (frontend)

Building a navigation is simple, access to the page tree is available through the common methods built into the ancestry gem. Just make sure you are only accessing published pages for your production site, using the published scope. Or if your page is translated, using the translated scope and the published scope.

2 level navigation example using simple-navigation

SimpleNavigation::Configuration.run do |navigation|
  navigation.items do |primary|
    # build first level
    Qbrick::Page.roots.published.translated.each do |page|
      primary.item page.id, page.title, page.link do |sub_item|
        # build second level
        page.children.published.translated.each do |subpage|
          sub_item.item subpage.id, subpage.title, subpage.link
        end
      end
    end
  end
end

Modifying the backend navigation

Simply override the default partial for the main navigation in your app with your own file at qbrick/cms/admin/_main_navigation.html.haml

Clone this wiki locally