Search code examples
twitter-bootstrap-3smarty

Alternately reverse div class values in smarty foreach loop


I'm trying to make a fancy banner module on my webstite to show alternately banners like this: enter image description here

But the result is like this... enter image description here

The code looks like this

{foreach blablabla}
    <div class="{cycle values="col-md-7,col-md-5"} col-sm-6 col-xs-12 pzero">
         <a href="{$slide.url|escape:'htmlall':'UTF-8'}" title="{$slide.description|escape:'htmlall':'UTF-8'}">
             <img src="#" alt="{$slide.legend|escape:'htmlall':'UTF-8'}" class="img-responsive" />
         </a>
    </div>
{/foreach}

Solution

  • Well you're doing a cycle with a set of 2 values, but what you really need are 4 (black,gray,gray,black)

    So just repeat them:

    {cycle values="col-md-7,col-md-5,col-md-5,col-md-7"}