0

I have an email where I need to display tiles dynamically based on conditions. Maximum 8 tiles need to be shown with maximum 2 tiles in 1 row. I have created only 2 tables for the tiles and have written for loop. Now, everything seems to work fine except when its only 1 tile. In case of 1 tile, its getting slightly shifted to right, however, in case of 3,5,7 tiles, everything is fine.

<table cellpadding="17" class="qe_none" width="250px">

%%[ for @counter = 1 to @count do IF MOD(@counter,2) != "0" THEN TreatAsContent( Concat('%','%[SET @row1= Row(@package',@counter, ',', @countername,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row2= Row(@package',@counter, ',', @counterprice,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row3= Row(@package',@counter, ',', @counterdate,')]%', '%' ) ) SET @name1 = Field(@row1,1) SET @price1 = Field(@row2,1) SET @date1 = Field(@row3,1) ]%%

<tr>

<td align="left" class="Zero" style="padding: 30px 30px 0px 0px;" valign="top" width="250px">
<table cellpadding="25" cellspacing="0" class="container" style="border-collapse: collapse; display:flex;" width="250px">

<tr>
<td align="left" style="background:#ffffff; border: 1px solid #EAEAEA;color:#4a4a4a;font-size:16px;line-height:24px;font-family:Helvetica,Arial,sans-serif; padding-right:0px;" valign="top" width="250px">
<span><b>%%=V(@name1)=%%</b><br>
Nächste Abrechung: %%=V(@date1)=%%<br>
Monatl. Kosten: %%=V(@price1)=%%</span></td></tr></table><img alt="" src="http://image.mailing.sky.de/lib/fe38117075640474721472/m/1/93644f5f-ccc7-4260-bff0-1b2ff54c8808.png" style="width: 100%; height: auto; padding: 0px; align:left; vertical-align: top;" width="245"></td><td class="Zero" style="padding: 30px 30px 0px 0px;" width="250px">
<table cellpadding="25" cellspacing="0" class="container" style="background:#fff; border-collapse: collapse; display:flex;" width="250px">
%%[IF @counter < @count THEN SET @dummycounter = ADD(@counter,"1") IF CONCAT('@flag',@dummycounter) != "0" THEN TreatAsContent( Concat('%','%[SET @row4= Row(@package',@dummycounter, ',', @countername,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row5= Row(@package',@dummycounter, ',', @counterprice,')]%', '%' ) ) TreatAsContent( Concat('%','%[SET @row6= Row(@package',@dummycounter, ',', @counterdate,')]%', '%' ) ) SET @name2 = Field(@row4,1) SET @price2 = Field(@row5,1) SET @date2 = Field(@row6,1) ]%%
<tr>
<td align="Left" style="background:#ffffff; border: 1px solid #EAEAEA;color:#4a4a4a;font-size:16px;line-height:24px;font-family:Helvetica,Arial,sans-serif;" valign="top" width="250px">
<span><b>%%=V(@name2)=%%</b><br>
Nächste Abrechung: %%=V(@date2)=%%<br>
Monatl. Kosten: %%=V(@price2)=%%</span></td></tr>%%[ENDIF ENDIF]%%</table>%%[IF @counter < @count THEN]%% <img alt="" src="http://image.mailing.sky.de/lib/fe38117075640474721472/m/1/93644f5f-ccc7-4260-bff0-1b2ff54c8808.png" style="width: 100%; height: auto; padding: 0px;align:left; vertical-align: top;" width="245">%%[ENDIF]%%</td></tr>%%[ ENDIF next @counter ]%%</table>
  • may I ask you why you putting px in the width attribute value? You need per cent sign value is not pixels. That's it! Also, your numbers don't stick together, your embedded Table is 250 pixels wide, but the parent td is 250 pixels wide and the padding is added too. – Neryus Jun 23 at 11:51
  • Thank you for the comment but could you be please more specific with the values ? The above code is perfectly working for all scenarios except in case of 1 tile to be shown. So, I need to be cautious while making changes as I don't want atleast my working scenarios to get distorted with my changes – Sourab Mund Jun 24 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.