« Bryan Larsen

navigation menu with more than 5 items

Posted by Bryan Larsen.

For most applications, one of the first things that is done is to replace the navigation menu with a full custom menu.

However for some applications like admin subsites, the standard navigation would be fine, if it wasn’t limited to 5 items.

Put this in your application.dryml (or admin_site.dryml) for a navigation that isn’t limited to 5 items.

<def tag="main-nav">
  <navigation class="main-nav" merge-attrs param="default">
    <nav-item href="#{base_url}/">Home</nav-item>
    <% models = Hobo::Model.all_models.select { |m| linkable?(m, :index) }.sort_by &:name -%>
    <repeat with="&models">
      <nav-item><ht key="#{this.name.tableize}.nav_item"><%= this.view_hints.model_name_plural %></ht></nav-item>
    </repeat>
  </navigation>
</def>

User contributed notes

  • On January 28, 2010 Owen said:

    Nice. Important feature.
  • On March 22, 2010 djcp said:

    I'm not sure if I'm doing something dumb (probably), but just putting this tag definition into app/views/taglibs/application.dryml (or admin_site.dryml) does not appear to have any effect.

    Is there something else I need to do?