Skip to content

Instantly share code, notes, and snippets.

@amdest
Created March 26, 2012 18:45
Show Gist options
  • Save amdest/2208623 to your computer and use it in GitHub Desktop.
Save amdest/2208623 to your computer and use it in GitHub Desktop.
Rails & Refinery CMS: navigation
<nav id='<%= dom_id %>' class='<%= css %>'>
<ul>
<%= render :partial => '/refinery/menu_branch', :collection => roots,
:locals => {
:hide_children => hide_children,
:sibling_count => (roots.length - 1),
:apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
} -%>
</ul>
</nav>
<li<%= ['', css].compact.join(' ').gsub(/ *$/, '').html_safe %>>
<%= link_to(menu_branch.title, main_app.url_for(menu_branch.url)) -%>
<% if (children = menu_branch.children unless hide_children).present? -%>
<ul class='clearfix'>
<%= render :partial => '/refinery/menu_branch', :collection => children,
:locals => {
:apply_css => local_assigns[:apply_css],
:hide_children => !!hide_children
} -%>
</ul>
<% end -%>
</li>
# using https://github.com/andi/simple-navigation
navigation.items do |primary|
Category.roots.map do |root|
primary.item ":root_#{root.id}", root.title, category_path(root) do |secondary|
root.descendants.map do |desc|
secondary.item ":desc_#{desc.id}", desc.title, category_path(desc)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment