Module: CategoryHelper
- Defined in:
- app/helpers/category_helper.rb
Overview
Methods for display Category
Instance Method Summary collapse
-
#display_categories(categories = Category::roots) ⇒ Object
Display all tree struct Category.
-
#display_category(category) ⇒ Object
Display one tree struct Category.
- #link_to_category(category) ⇒ Object
Instance Method Details
#display_categories(categories = Category::roots) ⇒ Object
Display all tree struct Category
4 5 6 7 8 9 10 |
# File 'app/helpers/category_helper.rb', line 4 def display_categories(categories=Category::roots) content = '<div class="categories">' categories.each do |category| content += display_category(category) end content += "</div>" end |
#display_category(category) ⇒ Object
Display one tree struct Category
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/category_helper.rb', line 13 def display_category(category) current_category = Category.find_by_id(params[:id]) content = '<div class="category">' (0..category.level).each do |i| content += " " end unless category.children.empty? content += link_to_function category.name, visual_effect('appear', "category_#{category.id}") content += "<div id=\"category_#{category.id}\" " + ((current_category && current_category.parent.eql?(category)) ? '' : 'style="display: none;"') + '>' category.children.each do |subcategory| content += display_category(subcategory) end content += "</div>" else content += link_to_unless current_category && current_category.eql?(category), category.name, :controller => 'catalog', :action => 'category', :id => category end content += "</div>" end |
#link_to_category(category) ⇒ Object
33 34 35 |
# File 'app/helpers/category_helper.rb', line 33 def link_to_category(category) end |