0

I have 2 tables to be rendered in my email based on conditions and loops. In case of even number of tables, everything is properly fine. However, in case of odd number of tables, the 1st table in the row is shifted to right. Every row should contain 2 tables. For eg: In case of 3 tables, 1st row of tables render properly, but the next table gets distorted. However, in case of 4 tables, the 3rd table is properly fine.

%%[ 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, ',', @counterdate,')]%', '%' ) ) SET @name1 = Field(@row1,1) SET @date1 = Field(@row2,1) ]%%
      <tr>
       <td class="Zero" style="padding: 30px 30px 0px 0px;" 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;" valign="top" width="250px">
            <span><b>%%=V(@name1)=%%</b><br>
            N&auml;chste Abrechung: %%=V(@date1)=%%</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; vertical-align: top;" width="245"></td>
            
            <td class="Zero" style="padding: 30px 30px 0px 0px;" 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, ',', @counterdate,')]%', '%' ) ) SET @name2 = Field(@row4,1) SET @date2 = Field(@row5,1) IF @name2 != "" THEN]%%<table cellpadding="25" cellspacing="0" class="container" style="background:#fff; 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;" valign="top" width="250px">
            <span><b>%%=V(@name2)=%%</b><br>
            N&auml;chste Abrechung: %%=V(@date2)=%%</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;vertical-align: top;" width="245">%%[ENDIF ENDIF ENDIF]%%</td></tr></table>%%[ ENDIF next @counter ]%%
  • Can you try adding <td align="left" valign="top"> to all <td> tags... And also add align="center" to all <table> tags. – Vishal Kumar C V Jun 18 at 11:32
  • I tried but it didn't work. Rather, in the case of 1 table in a row, the table is completely at the middle, which shouldn't be. – Sourab Mund Jun 19 at 7:56
  • Can you try to reformat/rearrange the table elements... Make sure ll data/image are placed inside <td> tag ....... For example the <img tag lying outside table tag only!... also place the conditional AMPscript code BEFORE <td> tag, not after!... hope this helps. – Vishal Kumar C V Jun 19 at 13:05
  • Sorry.. I didn't get your response. The <img> tag is already inside td tag as you mentioned then what exactly shall I change? Also, when I am placing Ampscript before td, then Marketing Cloud is by default placing it randomly somewhere at the top. – Sourab Mund Jun 19 at 19:57
0

I was housing the above code within a free-form content block,hence,the wysiwyg editor was trying to alter or move scripting. I tried using my code within an HTML-only content block instead, and the issue got resolved. Thank you

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.