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.

EE2.x: Help with switch variable

September 20, 2010 9:11pm

Subscribe [2]
  • #1 / Sep 20, 2010 9:11pm

    Kevpool1

    9 posts

    I’m having an issue with the switch variable. My code generates an outer div.team-row and then two inner divs, div.team-member & div.team-member-last

    The code works when the number of entries is equal or to put it another way there are two inner divs inside the row. However, if the number is odd then the closing div tag for the row is not generated.

    Here is my code

    Any help would be appreciated

    Thanks

    {exp:channel:entries channel="team_members" orderby="title" sort="asc"}
      {switch='<div class="team-row">|'}
        <div id='{url_title}' class='{switch="team-member|team-member-last"}'>
          <h2>{team_name}</h2>
    <p>      {team_excerpt}<br />
          <a href="http://{url_title_path=team}/">Read more</a><br />
          <a href="#top" class='top'>back to top</a><br />
        </div><br />
      {switch='|</div><!--/row-->'}    <br />
    {/exp:channel:entries}

    Moved to CodeShare Corner by Moderator

  • #2 / Sep 21, 2010 11:12am

    Sue Crocker

    26054 posts

    This is more of a CodeShare Corner kind of question. If you search for the words even odd you’ll find some discussions that may help.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases