Module: ProductHelper
- Defined in:
- app/helpers/product_helper.rb
Instance Method Summary collapse
- #display_all_products(products = Product.find_all_by_active_and_deleted(true,false), with_description = false) ⇒ Object
- #display_catalog(products) ⇒ Object
- #display_product(product, with_description = false, options = {}) ⇒ Object
- #display_product_page(product) ⇒ Object
- #display_product_page_attributes(product) ⇒ Object
- #link_to_product(product, name = nil, options = nil) ⇒ Object
Instance Method Details
#display_all_products(products = Product.find_all_by_active_and_deleted(true,false), with_description = false) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/product_helper.rb', line 18 def display_all_products(products=Product.find_all_by_active_and_deleted(true,false), with_description=false) content = '' products.each do |product| content << display_product(product, with_description) end content_tag :div, content, :class=>'products' end |
#display_catalog(products) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/product_helper.rb', line 3 def display_catalog(products) total = (products.is_a?(WillPaginate::Collection)) ? products.total_entries : products.size content = pluralize total, "result" products.in_groups_of(4).each do |products_| products_.each do |product| content += display_product(product) if product end content += '<div class="clear"></div>' end content += will_paginate(products).to_s if products.is_a?(WillPaginate::Collection) return content end |
#display_product(product, with_description = false, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/product_helper.rb', line 26 def display_product(product, with_description=false, ={}) #return I18n.t('no_product') unless product if product content = "<div id=\"product_#{product.id}\" class=\"product\">" if product..find_all_by_type('Picture').first content += "<div class='product_picture'>" content += image_tag(product..find_all_by_type('Picture').first.public_filename([:thumbnail_type] || :thumb)) content += "</div>" end content += "<div class='product_name'>" content += link_to_product product content += "</div>" content += "<div class='product_price'>" content += product.price_to_s(true) #content += product.price.to_s content += "</div>" content += "<div class='product_add_cart'>" content += link_to_add_cart(product) content += "</div>" if with_description content += "<div class='product_description'>" content += product.description content += "</div>" end content += "</div>" content += draggable_element("product_#{product.id}", :helper => '"clone"') end end |
#display_product_page(product) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/product_helper.rb', line 55 def display_product_page(product) content = '<div class="large">' content += '<div id="product_'+product.id.to_s+'" class="product_show">' content += '<div class="product_name">' content += '<h1>' content += "<div id='display_product_page_name_#{product.id}'>" content += product.name content += "</div>" content += '</h1>' content += '</div>' content += '<br /><br />' content += '<div class="product_description">' content += product.description content += '</div>' content += '<div class="product_picture" id="display_product_pictures_'+product.id.to_s+'">' product.pictures.each do |picture| content += (picture == product.pictures.first ? image_tag(picture.public_filename('')) : image_tag(picture.public_filename(:small))) end #content += image_tag(product.attachments.find_all_by_type('Picture').first.public_filename(:normal)) unless product.attachments.find_all_by_type('Picture').empty? content += '</div>' content += '<div class="product_attributes_groups" id="product_attributes_groups_' + product.id.to_s + '">' content += display_product_page_attributes(product) content += '</div>' content += '<div class="product_price">' content += '<div class="product_price_label">' content += 'price: ' content += '</div>' content += '<div class="product_price_value" id="display_product_page_price_' + product.id.to_s + '">' content += product.price_to_s(true) content += '</div>' content += '</div>' content += '<div class="product_link_cart" id="display_product_link_cart_' + product.id.to_s + '">' content += link_to_add_cart(product) content += '</div>' content += '</div>' content += '</div>' content += draggable_element("product_#{product.id}", :cursor => '"move"', :helper => "function(event) { return $('<div class=\"ui-widget-header\">#{escape_javascript(product.name)}</div>'); }" ) end |
#display_product_page_attributes(product) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/helpers/product_helper.rb', line 95 def display_product_page_attributes(product) content = "" return content unless product && product.product_type product.product_type.product_attributes.each do |attribute| content += "<div class='product_attribute_group_name'>" content += attribute.name + " : " content += "</div>" content += '<div class="product_attributes">' attribute.attribute_values.each do |attribute_value| content += '<div class="product_attribute">' content += attribute_value.name content += "</div>" end content += '</div>' content += "<div class='clear'></div>" end content end |
#link_to_product(product, name = nil, options = nil) ⇒ Object
114 115 116 117 |
# File 'app/helpers/product_helper.rb', line 114 def link_to_product(product, name=nil, =nil) name = product.name if name.nil? link_to name, [:seo,product], end |