ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

CSS Switch not working on Grid Rows

August 11, 2014 8:49pm

Subscribe [2]
  • #1 / Aug 11, 2014 8:49pm

    teamadna

    40 posts

    We are currently running EE 2.9.0.  When we try to use the ‘switch=’ variable it selects the first option for every post in the grid.

    Here is the code I am using:
    <pre><code>{exp:channel:entries entry_id="2" dynamic="off"}
    {alternating_panels_home}
    <!—Start of wide bar—>
    <div class=“wide-bar {switch='bg-even|bg-odd'}”><div class=“container”>

    <div class=“sixteen columns caps text-center”>

    {alternating_panels_home:content_title}

      </div>
      <div class=“sixteen columns cta-list”>
      {exp:ce_img:pair src="{alternating_panels_home:image}” max=“500”}
    {made}
    {/exp:ce_img:pair}
      {alternating_panels_home:content_partial_width}
      </div>
     
    </div></div>
    <!—end of wide bar—>
    {/alternating_panels_home}
    {/exp:channel:entries}</code></pre>

    and this is what is output:

    <!-- Start of wide bar -->
    <div class="wide-bar bg-even"><div class="container">
    
     <div class="sixteen columns caps text-center">
         <h3>First Panel</h3>
    <p>    </div><br />
      <div class="sixteen columns cta-list"><br />
       <br />
    /images/made/images/general_upload/placeholder-fish_500_500.jpg<br />
     <br />
        <ul><br />
    <li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li></ul>  <a href="http://walleyemanitoba.com.php53-12.ord1-1.websitetestlink.com/manage/index.php?S=2f563c3ad793b35b8cfd58efda3454c2&D=cp&D=cp&C=content_publish&M=entry_form&channel_id=1&template_id=1&parent_id=0#">learn more</a><br />
      </div><br />
      <br />
    </div></div><br />
    <!-- end of wide bar --></p>
    
    <p><!-- Start of wide bar --><br />
    <div class="wide-bar bg-even"><div class="container"></p>
    
    <p> <div class="sixteen columns caps text-center"><br />
        </p><h3>Second Panel</h3>
    <p>    </div><br />
      <div class="sixteen columns cta-list"><br />
       <br />
    /images/made/images/general_upload/placeholder-fish_500_500.jpg<br />
     <br />
        <ul><br />
    <li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li></ul>  <a href="http://walleyemanitoba.com.php53-12.ord1-1.websitetestlink.com/manage/index.php?S=2f563c3ad793b35b8cfd58efda3454c2&D=cp&D=cp&C=content_publish&M=entry_form&channel_id=1&template_id=1&parent_id=0#">learn more</a><br />
      </div><br />
      <br />
    </div></div><br />
    <!-- end of wide bar --></p>
    
    <p><!-- Start of wide bar --><br />
    <div class="wide-bar bg-even"><div class="container"></p>
    
    <p> <div class="sixteen columns caps text-center"><br />
        </p><h3>Third Panel</h3>
    <p>    </div><br />
      <div class="sixteen columns cta-list"><br />
       <br />
    /images/made/images/general_upload/placeholder-fish_500_500.jpg<br />
     <br />
        <ul><br />
    <li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li><li>Hard to argue with this point</li></ul>  <a href="http://walleyemanitoba.com.php53-12.ord1-1.websitetestlink.com/manage/index.php?S=2f563c3ad793b35b8cfd58efda3454c2&D=cp&D=cp&C=content_publish&M=entry_form&channel_id=1&template_id=1&parent_id=0#">learn more</a><br />
      </div><br />
      <br />
    </div></div><br />
    <!-- end of wide bar -->

  • #2 / Aug 13, 2014 11:10am

    Rob Allen

    3114 posts

    You need to include the grid field name in the switch variable as well eg,

    {alternating_panels_home}
    <!-- Start of wide bar -->
    <div class="wide-bar {alternating_panels_home:switch='bg-even|bg-odd'}">
    ...
    {/alternating_panels_home}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases