diff --git a/app/helpers/catalog_helper.rb b/app/helpers/catalog_helper.rb index 4783c3e..99ef1b4 100644 --- a/app/helpers/catalog_helper.rb +++ b/app/helpers/catalog_helper.rb @@ -3,4 +3,28 @@ module CatalogHelper include DisplayHelper include ManageProductsHelper + def breadcrumb(category) + start = link_to(_('Start'), {:action => 'index'}) + ancestors = category.ancestors.map { |c| link_to(c.name, {:action => 'index', :level => c.id}) }.reverse + current_level = content_tag('strong', category.name) + all_items = [start] + ancestors + [current_level] + content_tag('div', all_items.join(' → '), :id => 'breadcrumb') + end + + def category_link(category, sub = false) + count = profile.products.from_category(category).count + name = truncate(category.name, :length => 22 - count.to_s.size) + link_name = sub ? name : content_tag('strong', name) + link = link_to(link_name, {:action => 'index', :level => category.id}, :title => category.name) + content_tag('li', "#{link} (#{count})") if count > 0 + end + + def category_sub_links(category) + sub_categories = [] + category.children.each do |sub_category| + sub_categories << category_link(sub_category, true) + end + content_tag('ul', sub_categories) if sub_categories.size > 1 + end + end diff --git a/app/views/catalog/index.rhtml b/app/views/catalog/index.rhtml index 3ebdba0..2520c48 100644 --- a/app/views/catalog/index.rhtml +++ b/app/views/catalog/index.rhtml @@ -1,9 +1,24 @@ <% extra_content = [] %> <% extra_content_list = [] %> -