Permalink
Browse files

Adding support for an index link in the category tree.

  • Loading branch information...
1 parent f84486d commit ab8b3a0ecd53857ed24b5952d06949cada2cdb2f @bamnet committed Jan 31, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/acts_as_category_helper.rb
@@ -34,9 +34,16 @@ def aac_select_option(category, selected = '', parents_have_no_id = false)
# Sidebar menu tree
# -----------------
- def aac_tree(roots)
+ def aac_tree(roots, index = {:name => "", :path => ""})
result = "<ul class='tree_root'>"
+ if !index[:name].blank? && !index[:path].blank?
+ result += "<li class='root_link'>" + link_to(h(index[:name]), index[:path]) + "</li>"
+ result += '<ul>'
+ end
roots.each { |root| result += aac_tree_category(root) unless !root.allowed_to_read}
+ if !index[:name].blank? && !index[:path].blank?
+ result += '</ul>'
+ end
result += '</ul>'
end
memoize :aac_tree

0 comments on commit ab8b3a0

Please sign in to comment.