SOLVED

Re: How to update a tokens value to nothing? (not even a single space)

Go to solution
ernie
Level 2

How to update a tokens value to nothing? (not even a single space)

Hello Marketo Community!

 

I have created a list of client info, for a (guided) landing page template: 

 

<ul>

   <li>{{my.CON Client Name}}</li>

   <li>{{my.CON Client Address}}</li>

   <li>{{my.CON Client Phone Number}}</li>

</ul>


Now, let's say that the client does not want to show their phone number.

 

What I would like to be able to do, is to apply a display-none rule, to any empty list items, as such:

 

li:empty {

   display: none;

}


Here comes the problem. 

 

When I remove the value from the {{my.CON Client Phone Number}}, I get an error saying that "This field is required". A workaround would be to just input an empty space. But an empty space, would mean that the list-item is not empty. So, my display-none rule for empty list items would not work.

 

So, how to solve this particular problem? 

 

To my knowledge, there is no way of creating a token without a value. But is there some marketo-keyword for NULL or something similar, so that we get an empty list item in the output?

 

Thanks for the help in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
ernie
Level 2

Re: How to update a tokens value to nothing? (not even a single space)

Hello again!

 

I found the solution, and wanted to add it here in case someone else stumbled on the same problem.

 

Solution:

You can input a html comment tag as the tokens value: <!-- -->

This makes sure that you can update/create the token with a value, that is essentially empty (at least it will not render on the page).

I tried all major browsers (Safari/Chrome/Firefox) and it seems to work fine.

View solution in original post

3 REPLIES 3
ernie
Level 2

Re: How to update a tokens value to nothing? (not even a single space)

Hello again!

 

I found the solution, and wanted to add it here in case someone else stumbled on the same problem.

 

Solution:

You can input a html comment tag as the tokens value: <!-- -->

This makes sure that you can update/create the token with a value, that is essentially empty (at least it will not render on the page).

I tried all major browsers (Safari/Chrome/Firefox) and it seems to work fine.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to update a tokens value to nothing? (not even a single space)

Nicely done, Ernie.

 

My Firefox DE (81.0b5 and 82.0b9 after I let it update) doesn't show the bug you describe. The CSS spec is clear that comments are not considered:

 

only element nodes and content nodes (such as DOM [DOM-LEVEL-3-CORE] text nodes, CDATA nodes, and entity references) whose data has a non-zero length must be considered as affecting emptiness; comments, processing instructions, and other nodes must not affect whether an element is considered empty or not.

ernie
Level 2

Re: How to update a tokens value to nothing? (not even a single space)

Thanks SanfordWhiteman!

 

I just checked Firefox Developer Edition once more, and it does work as expected.

 

So I just updated my previous comment for future reference.

 

Have a good one!