Search code examples
asp.netif-statementhtml-emaildevelopment-environmentkentico

How can i add "if condition" around the anchor to check the field value empty or not?


I need to check if anchor URL added from the CMS or not?

Actually didn't find any useful link yet, but I need help that I've created a Email widget and when I drag and drop that I need to add anchor if url added in the field from the Kentico Email CMS if didn't add anything in the anchor field it should not add anchor html. Please help!

Thanks in Advance.

Here is the Anchor code in the widget:

<td>
<a href="{% Header_Circulation_Link %}">Read More</a>
</td>

Solution

  • {% if (Header_Circulation_Link == null) { %}
       <div>Its null</div>
    {% } else { %}
       <div>its not null</div>
    {% } %}
    

    Equality checks support all available object types, with the following special rules:

    Empty strings are equal to null

    See macro docs for more