catalog_helper.rb
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module CatalogHelper
include DisplayHelper
include ManageProductsHelper
def display_products_list(profile, products)
data = ''
extra_content = []
products.each { |product|
extra_content = @plugins.map(:catalog_item_extras, product).collect { |content| instance_eval(&content) } if @plugins
data << content_tag('li',
link_to_product(product, :class => 'product-pic', :style => 'background-image:url(%s)' % product.default_image(:portrait) ) +
content_tag('h3', link_to_product(product)) +
content_tag('ul',
(product.price ? content_tag('li', _('Price: %s') % ( "%.2f" % product.price), :class => 'product_price') : '') +
content_tag('li', product_category_name(profile, product.product_category), :class => 'product_category')
) +
(product.description ? content_tag('div',
txt2html(product.description),
:class => 'description') : tag('br',
:style => 'clear:both')) +
extra_content.join("\n"),
:class => 'product')
}
content_tag('h1', _('Products/Services')) + content_tag('ul', data, :id => 'product_list')
end
private
def product_category_name(profile, product_category)
if profile.enabled?
link_to_product_category(product_category)
else
product_category ? product_category.full_name(' → ') : _('Uncategorized product')
end
end
end