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 (targetData.segmentCode == "A"  ) { %>
Insert content here

<% } else if (targetData.segmentCode == "B"  ){ %>
Insert content here

<% } else if (targetData.segmentCode == "C"  ){ %>
Insert content here

<% } else { %>
Insert content here
<% } %>

Reference document