Witam. Mam taki problem chcę aby po najechaniu na zdjęcie w liście produktów mouseover pojawiało się drugie zdjęcie z kolei tak jak jest np. na stronie http://www.intymna.pl/c1381,33,0,2,,push-up produkt pierwszy z lewej.
Już próbowałem coś takiego zaprogramować w spree wyszło tak http://77.46.34.8:3000/t/bielizna/bielizna_korygujaca.
Kod pliku _products.html.erb teraz wygląda tak :
<%
paginated_products = @searcher.retrieve_products if params.key?(:keywords)
paginated_products ||= products
%>
<% if products.empty? %>
<%= t(:no_products_found) %>
<% elsif params.key?(:keywords) %>
<h6 class="search-results-title"><%= t(:search_results, :keywords => h(params[:keywords])) %></h6>
<% end %>
<% if products.any? %>
<ul id="products" class="inline product-listing" data-hook>
<% reset_cycle('default') %>
<% products.each do |product| %>
<% if Spree::Config[:show_zero_stock_products] || product.has_stock? %>
<li id="product_<%= product.id %>" class="columns three <%= cycle("alpha", "secondary", "", "omega secondary", :name => "classes") %>" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product">
<div class="product-image">
<%= link_to small_image(product, :itemprop => "image"), product, :itemprop => 'url' %>
<span>
<img src="/spree/products/22/small/erd.jpeg?1353765740" alt="">
</span>
</div>
<div class="producent"><a href="/">Kinga</a></div>
<div class="name">
<h3>
<%= link_to truncate(product.name, :length => 58), product, :class => "info", :itemprop => "name", :title => product.name %>
</h3>
</div>
<div class="info2">
<span>Wyprzedaż!</span>
<!--
Do wyboru: promocja, wyprzedaż, nowość lub wogóle bez span
<span class="new">Nowość!</span>
<span>Promocja</span>
-->
<span class="price selling" itemprop="price"><%= number_to_currency product.price %></span>
</div>
</li>
<% end %>
<% end %>
<% reset_cycle("classes") %>
</ul>
<% end %>
<% if paginated_products.respond_to?(:num_pages) %>
<%= paginate paginated_products %>
<% end %>
Kod pliku products_controller.rb
module Spree
class ProductsController < BaseController
before_filter :load_product, :only => :show
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
helper 'spree/taxons'
respond_to :html
def index
@searcher = Config.searcher_class.new(params)
@products = @searcher.retrieve_products
respond_with(@products)
end
def show
return unless @product
@variants = Variant.active.includes([:option_values, :images]).where(:product_id => @product.id)
@product_properties = ProductProperty.includes(:property).where(:product_id => @product.id)
referer = request.env['HTTP_REFERER']
if referer
referer_path = URI.parse(request.env['HTTP_REFERER']).path
if referer_path && referer_path.match(/\/t\/(.*)/)
@taxon = Taxon.find_by_permalink($1)
end
end
respond_with(@product)
end
private
def accurate_title
@product ? @product.name : super
end
def load_product
@product = Product.active.find_by_permalink!(params[:id])
end
end
end
Nigdzie nie mogę znaleść najmniejszej podpowiedzi jak to zrobić. W tym momencie poprostu jest postawiony span którym kontroluje javascript i włącz go po najechaniu na zdjęcie. Coś mi się zdaje że będę musiał przebudować trochę paperclipa abym mógł dostawić kolejne zdjęcie