Skip to content

Instantly share code, notes, and snippets.

@FineLineAutomation
Created February 13, 2014 15:48
Show Gist options
  • Save FineLineAutomation/8977525 to your computer and use it in GitHub Desktop.
Save FineLineAutomation/8977525 to your computer and use it in GitHub Desktop.
# link to cart better
Spree::BaseHelper.module_eval do
def taxons_tree(root_taxon, current_taxon, max_level = 1, root_css_class = nil)
return '' if max_level < 1 || root_taxon.children.empty?
content_tag :ul, :class => root_css_class do
root_taxon.children.map do |taxon|
css_class = (taxon.children.empty? || max_level < 2) ? "no_sub_menu" : "has_sub_menu"
i_class = (css_class == "no_sub_menu") ? "fi-minus" : "fi-plus"
content_tag :li, :class => css_class do
content_tag(:i, :class => "nav-collapse " + i_class) do end +
link_to(taxon.name, seo_url(taxon)) +
taxons_tree(taxon, current_taxon, max_level - 1, "nested")
end
end.join("\n").html_safe
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment