Skip to content

Active Navigation Item Name

andi edited this page Dec 27, 2010 · 3 revisions

In addition to render_navigation there is another helper method called active_navigation_item_name to just render the name of the currently active navigation item. This can be useful for example if you have a sidebar and the heading of the sidebar is always equal to the currently active secondary navigation. To achieve this you would call the helper method like this (using haml):

.sidebar
  %h1= active_navigation_item_name(:level => 2)

You can pass the following options to active_navigation_item_name:

  • :level – this option determines for which level you want to render the name of the currently active navigation item. Use :level => :all to render the name of the most specific/deepest item possible. Use a specific level (e.g. :level => 1) to always render the active item name of the same level. Defaults to :all.
Clone this wiki locally