1

I want to display 3 images per row. but the code show first row with 2(two) images then it shows 3 images next row. where is the problem of the code?

<table style="width: 99%;padding-top:30px;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
             <tbody> 


              <tr>
               {foreach from=$execommittee item=v name=cat}

                 {if $smarty.foreach.cat.iteration % 3 == 0 && $smarty.foreach.cat.iteration > 0}

              </tr>
              <tr>

               {/if}
               <td width="142">
                <p style="text-align: center;" align="justify">
                 <img src="themes/{$themes}/resources/images/publications/{$v.efilename}" border="0" width="142" height="152" /></a></p>
                <p style="text-align: center;" align="justify">{$v.ename}</p>
               </td>

               {/foreach}
             </tr>

             </tbody>
            </table>
Strawberry
  • 33,750
  • 13
  • 40
  • 57
prasun
  • 63
  • 8
  • `$smarty.foreach.cat.iteration` will always be more than 0, because it starts at 1 (http://www.smarty.net/docsv2/en/language.function.foreach.tpl#foreach.property.iteration), so you don't need to have that in your `if` statement. – guessimtoolate Jan 26 '14 at 10:08

1 Answers1

3
<table style="width: 99%;padding-top:30px;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
             <tbody> 



               {foreach from=$execommittee item=v name=cat}
                 <tr>
                 {if $smarty.foreach.cat.iteration % 3 == 0 && $smarty.foreach.cat.iteration > 0}

              </tr>
              <tr>

               {/if}
               <td width="142">
                <p style="text-align: center;" align="justify">
                 <img src="themes/{$themes}/resources/images/publications/{$v.efilename}" border="0" width="142" height="152" /></a></p>
                <p style="text-align: center;" align="justify">{$v.ename}</p>
                  </td>
                 </tr> 
               {/foreach}


             </tbody>
            </table>

your tr tags should be inside your loop. I'm not sure about that if statement, i think its not needed.

Gert B.
  • 2,282
  • 18
  • 21