Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing Spree taxonomy tree on product page

I'm running Spree 2.2. I'm trying to get the standard taxonomy/filter list to appear on each individual product page in Spree, but I cannot find where it decides that there's sidebar content to be displayed. If anyone can shed any light on where/how that's decided I'd be most grateful.

like image 258
TheMinimalCriminal Avatar asked Nov 01 '22 22:11

TheMinimalCriminal


1 Answers

On the front-end part of spree, more specific, on the index view of the products controller, route spree_frontend/app/views/spree/products/index.html.erb at the beginning of the file, it get's decided whether there will be displayed the taxons or not:

<% content_for :sidebar do %>
  <div data-hook="homepage_sidebar_navigation">
    <% if "spree/products" == params[:controller] && @taxon %>
      <%= render :partial => 'spree/shared/filters' %>
    <% else %>
      <%= render :partial => 'spree/shared/taxonomies' %>
    <% end %>
  </div> 
<% end %>

So what you can do is to write an override pointing at any part of the products/show view, in particular i suggest after the product_left_part_wrap" data-hook, wich is a wrapper for the sidebar on the products show view, so your deface could look something like this:

Deface::Override.new(
  :virtual_path => 'spree/products/show',
  :name => 'add_map_to_product_show',
  :insert_after => '[data-hook="product_left_part_wrap"]',
  :partial => "spree/products/the_taxons_and_filters"
)

And inside the file named _the_taxons_and_filters.html.erb located on app/views/spree/products/ you can add the code from above and include the taxons filters. Hope this was helpful.

like image 181
aledustet Avatar answered Nov 09 '22 16:11

aledustet