ruby-on-railsspreedeface

Deface _products data-hook


I want to add taxonomies from sidebar to main page, instead of list of products, but my deface is not working.

Deface::Override.new(
:virtual_path => 'spree/shared/_products',
:name => 'change view',
:replace => "[data-hook='homepage_products']",
:text => "
            <% max_level = Spree::Config[:max_level_in_taxons_menu] || 1 %>
            <nav id='taxonomies2' class='sidebar-item' data-hook>
                <% @taxonomies.each do |taxonomy| %>
                    <% cache [I18n.locale, taxonomy, max_level] do %>
                        <h4 class='taxonomy-root'><%= Spree.t(:shop_by_taxonomy, :taxonomy => taxonomy.name) %></h4>
                        <%= taxons_tree(taxonomy.root, @taxon, max_level) %>
                    <% end %>
                <% end %>
            </nav> ")

I am stuck at this really badly.


Solution

  • You should replace the virtual path with the homepage index view one: spree/home/index, where the element you are trying to replace is placed.

    Also, I'm not sure name should contain a space, try changing it with "change_view". Always be sure the name is unique and restart your server when adding a new deface override file.