Help on coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aeroheli
Forum Newbie
Posts: 2
Joined: Wed May 06, 2009 8:44 pm

Help on coding

Post by aeroheli »

Hi, I would like to add a condition in this code to have the forum insert "</tr><tr>" if the {counter} hits 3, can someone help me? Thank you so much!


Code: Select all

{foreach item="image" from=$records}
 
 
        <td>
        {if $use_fancy_urls}
            <a href="listings/view/{$image.make|strip:"-"}/{$image.model|strip:"-"}/
 
{$image.listingid}/"><img src="{$image.imagethumbpath}" title="{$smarty.const.IMAGE} {counter}" 
 
alt="{$smarty.const.IMAGE} {counter}" /></a><br><br><b>{$image.ad_title}</b><br></td>
 
 
 
        {else}
            <a href="listings.php?make={$image.make|strip:"-"}&model=
 
{$image.model|strip:"-"}&id={$image.listingid}"><img src="{$image.imagethumbpath}" 
 
title="{$smarty.const.IMAGE} {counter}" alt="{$smarty.const.IMAGE} {counter}" /></a><br><br><b>
 
{$image.ad_title}</b><br></td>
 
        {/if}
    
 
 
 
 
{/foreach}
Last edited by Benjamin on Thu May 07, 2009 1:29 am, edited 1 time in total.
Reason: Changed [quote] to [code=php]
User avatar
Gabriel
Forum Commoner
Posts: 41
Joined: Wed May 06, 2009 8:12 pm
Location: Las Vegas

Re: Help on coding

Post by Gabriel »

That's not too hard. Insert this wherever you want that:

Code: Select all

{if $counter == 3}
</tr><tr>
{/if}
aeroheli
Forum Newbie
Posts: 2
Joined: Wed May 06, 2009 8:44 pm

Re: Help on coding

Post by aeroheli »

Doesn't work :(
User avatar
Gabriel
Forum Commoner
Posts: 41
Joined: Wed May 06, 2009 8:12 pm
Location: Las Vegas

Re: Help on coding

Post by Gabriel »

It looks like you're using Smarty. Maybe I have something wrong or you're inserting it incorrectly. Have a look at the Smarty conditionals manual. If you've inserted it, look for your "templates_c" directory or something similar and delete the files in it to force Smarty to regenerate any templates it may be caching. That should fix it. If not, let me know.
Post Reply