Module: TaxonsHelper

Defined in:
app/helpers/taxons_helper.rb

Instance Method Summary collapse

Instance Method Details



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/taxons_helper.rb', line 2

def breadcrumbs(taxon, separator=" » ")
  return "" if current_page?("/")
  crumbs = [(:li, link_to(t(:home) , root_path) + separator)]
  if taxon
    crumbs << (:li, link_to(t('products') , products_path) + separator)
    crumbs << taxon.ancestors.reverse.collect { |ancestor| (:li, link_to(ancestor.name , seo_url(ancestor)) + separator) } unless taxon.ancestors.empty?
    crumbs << (:li, (:span, taxon.name))
  else
    crumbs << (:li, (:span, t('products')))
  end
  crumb_list = (:ul, crumbs)
  (:div, crumb_list + (:br, nil, :class => 'clear'), :class => 'breadcrumbs')
end

#taxon_preview(taxon, max = 5) ⇒ Object

Retrieves the collection of products to display when “previewing” a taxon. This is abstracted into a helper so that we can use configurations as well as make it easier for end users to override this determination. One idea is to show the most popular products for a particular taxon (that is an exercise left to the developer.)



20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/taxons_helper.rb', line 20

def taxon_preview(taxon, max=5)
  products = taxon.products.active.find(:all, :limit => max)
  if (products.size < max) && Spree::Config[:show_descendents]
    taxon.descendents.each do |taxon|
      to_get = max - products.length
      products += taxon.products.active.find(:all, :limit => to_get)
      break if products.size >= max
    end
  end
  products
end