Sha256: 83ae57b5d3a4db6f0fc1e3381e0d9ced09935b8f6ad0eac6a8416c6f1eb0ebf2

Contents?: true

Size: 1.49 KB

Versions: 19

Compression:

Stored size: 1.49 KB

Contents

module TaxonsHelper
  def breadcrumbs(taxon, separator=" » ")
    return "" if current_page?("/")
    separator = raw(separator)
    crumbs = [content_tag(:li, link_to(t(:home) , root_path) + separator)]
    if taxon
      crumbs << content_tag(:li, link_to(t('products') , products_path) + separator)
      crumbs << taxon.ancestors.collect { |ancestor| content_tag(:li, link_to(ancestor.name , seo_url(ancestor)) + separator) } unless taxon.ancestors.empty?
      crumbs << content_tag(:li, content_tag(:span, taxon.name))
    else
      crumbs << content_tag(:li, content_tag(:span, t('products')))
    end
    crumb_list = content_tag(:ul, raw(crumbs.flatten.map{|li| li.mb_chars}.join))
    content_tag(:div, crumb_list + tag(:br, {:class => 'clear'}, false, true), :class => 'breadcrumbs')
  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, max=4)
    products = taxon.active_products.limit(max)
    if (products.size < max) && Spree::Config[:show_descendents]
      taxon.descendants.each do |taxon|
        to_get = max - products.length
        products += taxon.active_products.limit(to_get)
        break if products.size >= max
      end
    end
    products
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
apispree_core-0.0.0 app/helpers/taxons_helper.rb
My-Commerce_core-1.1.0 app/helpers/taxons_helper.rb
My-Commerce_core-1.0.0 app/helpers/taxons_helper.rb
MyCommerceapi-1.0.0 core/app/helpers/taxons_helper.rb
MyCommerce-0.0.3 core/app/helpers/taxons_helper.rb
rfcommerce_core-0.0.3 app/helpers/taxons_helper.rb
spree_core-0.60.6 app/helpers/taxons_helper.rb
spree_core-0.60.5 app/helpers/taxons_helper.rb
spree_core-0.50.4 app/helpers/taxons_helper.rb
spree_core-0.60.4 app/helpers/taxons_helper.rb
spree_core-0.50.3 app/helpers/taxons_helper.rb
spree_core-0.60.3 app/helpers/taxons_helper.rb
spree_core-0.60.2 app/helpers/taxons_helper.rb
spree_core-0.60.1 app/helpers/taxons_helper.rb
spree_core-0.60.0 app/helpers/taxons_helper.rb
spree_core-0.60.0.RC1 app/helpers/taxons_helper.rb
spree_core-0.50.2 app/helpers/taxons_helper.rb
spree_core-0.50.1 app/helpers/taxons_helper.rb
spree_core-0.50.0 app/helpers/taxons_helper.rb