Expand my Community achievements bar.

Multiple "IF" conditions- conditional content in HTML

Avatar

Level 2

We have 6 different blocks of code (that we are putting into personalization blocks) that a recipient could receive.  How would I code an if/else statement for these (including the 1 generic version = else?).  Would it be something like below?

 

<% if ( targetData.segmentCode == "A" )  { %>
<%@ include view='A' %>

<% if ( targetData.segmentCode == "B" )  { %>
<%@ include view='B' %>

<% } else { %>
<%@ include view='C' %>
<% } %>

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

Hi @KristenCo4 ,

 

<% if (language == "EN" ) { %>

Insert content here

 

<% } Else if (language == "FR" ){ %>

Insert content here

 

<% } Else if (language == "GE" ){ %>

Insert content here

 

<% } else { %>

Insert content here

<% } %>

 

Reference document