简体   繁体   中英

AMPScript: trying to insert hidden fields

I'm working on some email that will be deployed via Exact Target. We have a lot of AMPScript dictating what is going on within the email(s). The content blocks of the email are dynamically filled, and when a field is left empty there is still a call made to that table section, which then inserts a blank space on the email. Thus throwing the design out of whack. My question is, is there anyway I can have those empty cells completely removed from the page when not in use?

here is the code sample ...

Set @SendLog_blockC1 = lookup("RaceDataSendLog","BLK_C1","SubID",@SubLookup,"JobID",@JobLookup,"BatchID",@BatchLookup)
...
...
...
Set @blockC1 = Concat("My Contents\Newsletter\",@SendLog_blockC1)
....
....
....
....
%%[IF empty(@blockC1) THEN]%%

%%[ELSE]%%
<tr>
<td align="left" valign="top" >

%%=ContentAreaByName(@blockC1,"",0)=%%

</td>
</tr>
%%[ENDIF]%%

Thank you in advance.

On the assumption you're referring to that space above your ELSE - this should work:

<!--%%[
IF empty(@blockC1) THEN
ELSE]%%-->
<tr>
<td align="left" valign="top" >
%%=ContentAreaByName(@blockC1,"",0)=%%
</td>
</tr>
<!--%%[ENDIF]%%-->

This will hide the AMPscript in the HTML, in addition - you don't really need the IF to produce the space, you can just have the ELSE right after it.

and thank you for your responses. I was finally able to resolve the issue of the extra spacing.

What I did was remove the <tr> and <td> tags from around the if/else statements. I then placed those <tr> and <td> tags around the content blocks that are brought in by the PM's when they decide which blocks to use. This solved the problem of the extra spacing. Client is happy!!!

Thanks again guys!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM