Hi,
Here is a snipplet of my code in my tpl:
<iw_iterate list = 'dcr.FeaturedItems' var = 'abtproduct' iteration = 'product_count' >
<iw_perl>
<![CDATA[
my $remainder = ($product_count + 1)%2;
if ( $remainder == 0){
my $prod = iwpt_dcr_value( 'dcr.FeaturedItems.ProductName[$product_count - 1]' ) ;
my $prod2 = iwpt_dcr_value( 'abtproduct.ProductName' ) ;
my $prodImage = iwpt_dcr_value( 'dcr.FeaturedItems.ProductImage[$product_count - 1]' );
my $prodImage2 = iwpt_dcr_value( 'abtproduct.ProductImage');
my $prodDescription = iwpt_dcr_value( 'dcr.FeaturedItems.ProductDescription[$product_count - 1]' );
my $prodDescription2 = iwpt_dcr_value( 'abtproduct.ProductDescription');
my ( $key , $value ) = split( ';' , $prod , 2 ) ;
my ( $key2 , $value2 ) = split( ';' , $prod2 , 2 ) ;
iwpt_output( '<tr>
<td colspan="2"></td>
<td class="midAlign"><img src="/b2b/images/arrow_red.gif" width="7" height="7" >
</td>
<td><a href="/b2b/DisplayProduct?hid='
. $key . '" class="latest">'
. $value . '</a>
</td>
<td></td>
<td></td>
<td class="midAlign"><img src="/b2b/images/arrow_red.gif" width="7"</td>
<td><a href="/b2b/DisplayProduct?hid='
. $key2 . '" class="latest">'
. $value2 . '</a></td>
<td></td>
</tr>' ) ;
iwpt_output( '<tr>
<td></td>
<td>
<img src="' . $prodImage . '" width="85" height="65">
</td>
<td></td>
<td>
' . $prodDescription . $product_count . '
</td>
<td></td>
<td>
<img src="' . $prodImage2 . '" width="85" height="65">
</td>
<td></td>
<td>
' . $prodDescription2 .
@bl . '
</td>
<td></td>
</tr>
' ) ;
}
]]>
</iw_perl>
</iw_iterate>
I have a replicant 'FeaturedItems' which has 4 occurences. What I want to do....is only process on the 2nd and 4th occurrence.
When I am in the 2nd or 4th occurrence ( $product_count = 1 and 3 respectfully), I need to go back to (-1) previous occurrence. You can see I tried to do that by doing $product_count - 1.
This code is not working. I am getting results for occurrence 1,2, and 4. But, for some reason I am not getting any data from the 3rd occurrence. Ii checked my data record and there is definitely data in 3rd occurrence. Either there is a bug in my code or I need another approach to handle my situation. I would appreciate any suggestions!
Thanks in advance,
mccalla