IF ELSE condition moved in HTML content in DCE editor

Learn how to implement IF ELSE conditions in HTML content for the DCE editor in Campaign Classic.

Description description

Environment

  • Adobe Campaign
  • Adobe Campaign Classic
  • Adobe Campaign Classic V7

Issue/Symptoms

How can you add a IF ELSE condition into the HTML content and import the content in the DCE editor mode, for example:

<table>

<% if (recipient.email == 'xxxxx@email.com' ) { %>

<tr>

<td>A</td>

</tr>

<% } else { %>

<tr>

<td>B<td>

</tr>

<% } %>

</table>

The purpose of the condition is to display certain parts of the content to recipients if their email address equals xxxxx@email.com. After saving the message we observe that the IF ELSE condition is moved to the top of the email content.

Resolution resolution

This behavior is expected.

With evolving HTML specs and modern specs, non-table tags like [ (less-than)(percent-sign) (< )(%)] , [ (percent-sign)(greater-than) (%)(> )]  tags, or even regular HTML tags like img tags and div tags are not allowed between tr tags or td tags.

All such tags are pushed out of the table tag by the browser.

This is the correct usage:

<% if (recipient.email == 'xxxxx@email.com' ) { %>
<table>
<tr>
<td>A</td>
</tr>
</table>
<% } else { %>
<table>
<tr>
<td>B<td>
</tr>
</table>
<% } %>

This problem can be observed in V7 9349 Campaign Classic, but not in lower builds.

This is because in older builds, the underlying control was Internet Explorer 7, and in 9349 it is IE 11 (or Edge Chromium depending on the case).

This adjustment was made because newer browsers are more HTML compliant than older ones.

You should make the content as per the HTML specification, which is followed by all modern browsers because the content will not only be viewed in the Campaign but outside the Campaign by the users in their browsers and email clients (like Outlook).

If you fail to do so, it may lead to HTML UI discrepancies.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f