Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is easy to get confused on, so lets look at what's happening. The sidebar code is:</p> <p><a href="https://github.com/spree/spree/blob/2d31d8a69d66e2555e00f67e3227a54a531aa6b8/frontend/app/views/spree/shared/_sidebar.html.erb" rel="nofollow">https://github.com/spree/spree/blob/2d31d8a69d66e2555e00f67e3227a54a531aa6b8/frontend/app/views/spree/shared/_sidebar.html.erb</a></p> <pre><code>&lt;aside id="sidebar" class="columns four" data-hook&gt; &lt;%= yield :sidebar %&gt; &lt;/aside&gt; </code></pre> <p><a href="https://github.com/spree/spree/blob/v2.1.2/frontend/app/views/spree/home/index.html.erb" rel="nofollow">https://github.com/spree/spree/blob/v2.1.2/frontend/app/views/spree/home/index.html.erb</a></p> <pre><code>&lt;% content_for :sidebar do %&gt; &lt;div data-hook="homepage_sidebar_navigation"&gt; &lt;%= render :partial =&gt; 'spree/shared/taxonomies' %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;div data-hook="homepage_products"&gt; &lt;%= render :partial =&gt; 'spree/shared/products', :locals =&gt; { :products =&gt; @products } %&gt; &lt;/div&gt; </code></pre> <p>When this is evaluated, the stuff <strong>within</strong> <code>content_for :sidebar</code> will replace <code>yield :sidebar</code></p> <p>Your problem is that when you're doing insert_before. You get this:</p> <pre><code>&lt;h1&gt;Hola&lt;/h1&gt; &lt;% content_for :sidebar do %&gt; &lt;!-- stuff that goes in to the sidebar --&gt; &lt;% end %&gt; &lt;div data-hook="homepage_products"&gt;...&lt;/div&gt; </code></pre> <p>The content_for can occur at any point in this file, it doesn't really matter since it's just saying what goes in the yield. So in the output, it will come before the homepage_products div, which is what you get in your output.</p> <p>Insert_after does the following:</p> <pre><code>&lt;% content_for :sidebar do %&gt; &lt;h1&gt;Hola&lt;/h1&gt; &lt;!-- stuff that goes in to the sidebar --&gt; &lt;% end %&gt; &lt;div data-hook="homepage_products"&gt;...&lt;/div&gt; </code></pre> <p>So I'd expect that to appear within the section that's being yielded. Something like this:</p> <pre><code>&lt;aside id="sidebar" class="columns four" data-hook&gt; &lt;h1&gt;Hola&lt;/h1&gt; &lt;!-- stuff that goes in to the sidebar --&gt; &lt;/aside&gt; </code></pre> <p>Which is also what you see.</p> <p>If you want something to appear before the sidebar, as in your example, you should do a different override. You should override <code>spree/shared/_sidebar</code> and insert_before <code>#sidebar</code>.</p> <p>Hope that clears things up.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload