My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
117
attachment: mvc_product_view.diff
(3.6 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Index: plugins/substruct/app/helpers/application_helper.rb
===================================================================
--- plugins/substruct/app/helpers/application_helper.rb (revision 120)
+++ plugins/substruct/app/helpers/application_helper.rb (working copy)
@@ -35,35 +35,6 @@
return str
end
-
- def make_product(image_path, link, title, cost=nil, on_sale=false, is_new=false)
- product = '<div class="product">'
- # Add 'on sale' image if applicable
- if on_sale
- product << image_tag('public-ui/icons/on-sale.gif', :alt => 'On Sale', :class => 'icon', :plugin => 'substruct')
- end
- if is_new && !on_sale
- product << image_tag('public-ui/icons/new.gif', :alt => 'New', :class => 'icon', :plugin => 'substruct')
- end
- product << %Q/
- <div class="product_top"><\/div>
- <div class="product_main">
- <div class="product_image">
- <a href="#{link}">#{image_tag(image_path, :alt => title)}<\/a><br\/>
- <\/div>
- <div class="product_title">
- <a href="#{link}\">#{title}<\/a><br\/>
- <\/div>
- /
- if cost
- product << %Q/ <span class="money">#{sub_number_to_currency(cost)}<\/span> /
- end
- product << %Q/
- <\/div>
- <div class="product_bottom"><\/div>
- /
- return product << '</div>'
- end
# When browsing the store by tags we need to know what
# is the main "parent" tag or tag group.
Index: plugins/substruct/app/models/product.rb
===================================================================
--- plugins/substruct/app/models/product.rb (revision 120)
+++ plugins/substruct/app/models/product.rb (working copy)
@@ -116,6 +116,10 @@
end
end
end
+
+ def display_price?
+ display_price > 0
+ end
def quantity
if self.variations.count == 0
Index: plugins/substruct/app/views/store/_product.rhtml
===================================================================
--- plugins/substruct/app/views/store/_product.rhtml (revision 120)
+++ plugins/substruct/app/views/store/_product.rhtml (working copy)
@@ -1,18 +1,30 @@
-<%
- @image = product.images[0]
- if @image then
- image_url = @image.public_filename(:small)
- else
- image_url = '/plugin_assets/substruct/images/public-ui/no-product-image.gif'
- end
--%>
-<%=
- make_product(
- image_url,
- url_for(:controller => 'store', :action => 'show', :id => product.code),
- product.name,
- product.display_price,
- product.is_on_sale?,
- product.is_new?
- )
--%>
\ No newline at end of file
+<div class="product">
+ <%= if product.is_on_sale?
+ image_tag('public-ui/icons/on-sale.gif', :alt => 'On Sale', :class => 'icon', :plugin => 'substruct')
+ elsif product.is_new?
+ image_tag('public-ui/icons/new.gif', :alt => 'New', :class => 'icon', :plugin => 'substruct')
+ end
+ %>
+
+ <div class="product_top"><\/div>
+ <div class="product_main">
+ <div class="product_image">
+ <% if product.images.empty?
+ image = image_tag('images/public-ui/no-product-image.gif',:plugin=>'substruct', :alt=>product.name )
+ else
+ image = image_tag(image.public_filename(:small), :alt=>product.name)
+ end
+ %>
+ <%= link_to image, :controller=>'store', :action=>'show', :id=>product.code %>
+
+ </div>
+ <div class="product_title">
+ <%= link_to product.name, :controller=>'store', :action=>'show', :id=>product.code %>
+ </div>
+ <% if product.display_price? %>
+ <span class="money"><%= sub_number_to_currency(product.display_price) %></span>
+ <% end %>
+ </div>
+ <div class="product_bottom"></div>
+</div>
+
Powered by
Google Project Hosting