How can I replace dmx-text with a condition?

Hi,

I would like to replace dmx-text with a condition.
For instance, if entrytypefee ==0, I would like to replace entrytypefee with “Free”.
I set as follows though, it didn’t work. how can I solve this?

<dd class="text-secondary" dmx-text="entrytypefee" dmx-class:stylefree="entrytypefee==0"></dd>
  .stylefree{
    visibility: hidden; 
    position: relative;
  }
  .stylefree:after{
    color: #6c757d!important;
    font-size: 14px;
    content:"Free";
  }

It’s easy, no need to use additional CSS for this, just the ternary operator:

<dd class="text-secondary" dmx-text="entrytypefee == 0 ? 'Free' : entrytypefee" dmx-class:stylefree="entrytypefee==0"></dd>
1 Like

It worked! thanks a lot.
btw, I removed dmx-class from your reply.

If I have more than two possible values of my variable I want to show different text for each then I just have lots of paragraphs and show each one based on one specific variable value…

You can still use the ternary operator:

condition ? value1 : condition2 ? value2 : value3
4 Likes