Sha256: 80f56a59cb46b3012a3998d8b26e15a47bf5bba455ef63640351a753b7d5886f

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module TaxonsHelper
  def breadcrumbs(taxon)
    crumbs = "<div class='breadcrumbs'>"
    crumbs += link_to t('Products'), products_url
    unless taxon
      return crumbs += "</div>"
    end
    crumbs += image_tag("breadcrumb.gif")
    unless taxon.ancestors.empty?
      crumbs += taxon.ancestors.reverse.collect { |ancestor| link_to ancestor.name, taxon_path(ancestor) }.join( image_tag("breadcrumb.gif") )
      crumbs += image_tag("breadcrumb.gif")
    end
    crumbs += taxon.name
    crumbs += "</div>"
  end
  
  # 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.) 
  def taxon_preview(taxon)
    products = taxon.products[0..4]
    return products unless products.size < 5
    if Spree::Config[:show_descendents]
      taxon.descendents.each do |taxon|
        products += taxon.products[0..4]
        break if products.size >= 5
      end
    end
    products[0..4]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree-0.4.0 app/helpers/taxons_helper.rb
spree-0.4.1 app/helpers/taxons_helper.rb
spree-0.5.0 app/helpers/taxons_helper.rb
spree-0.5.1 app/helpers/taxons_helper.rb