add class to default widget if row data is hot or top

This commit is contained in:
Matt K. Fu 2013-07-16 17:41:22 +08:00
parent c1316f72a0
commit aea15fa622
4 changed files with 10 additions and 3 deletions

View File

@ -3,6 +3,13 @@ module DefaultWidgetHelper
I18n.t("#{@page_part.module_app.key}.default_widget.#{field}")
end
def get_top_hot_class(row_data)
class_attr = []
class_attr << 'data_is_hot' if( row_data.is_hot? rescue false )
class_attr << 'data_is_top' if( row_data.is_top? rescue false)
return class_attr.join(" ")
end
def link_to_field(row_data,field, switch, options=nil)
method_ary = @page_part.module_app.widget_fields_link_method
field = field.to_sym

View File

@ -9,7 +9,7 @@
</tr>
</thead>
<% @data.each do |row_data| %>
<tr>
<tr class="<%= get_top_hot_class(row_data) %>">
<% @frontend_field_names.each_with_index do |field,index|%>
<%= content_tag(:td,content_tag(:span,link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]))unless field.blank?%>
<% end %>

View File

@ -1,7 +1,7 @@
<%= content_tag :div,:class=>@tag_class do%>
<ul class="default_widget_list">
<% @data.each do |row_data| %>
<%= content_tag(:li) do %>
<%= content_tag(:li,:class=>get_top_hot_class(row_data)) do %>
<div class="img app-pic">
<%= image_tag row_data.send(@widget_image_field)%>
</div>

View File

@ -4,7 +4,7 @@
</div>
<ul class="default_widget_list">
<% @data.each do |row_data| %>
<%= content_tag(:li) do %>
<%= content_tag(:li,:class=>get_top_hot_class(row_data)) do %>
<% @frontend_field_names.each_with_index do |field,index|%>
<%= content_tag(:span, link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]) unless field.blank?%>
<% end %>