Should I use boolean to toggle off a space in email? | Community
Skip to main content
New Participant
March 29, 2021
Question

Should I use boolean to toggle off a space in email?

  • March 29, 2021
  • 2 replies
  • 4662 views

I had this idea to use in the email builder. 

I was given a design where we have space between modules, and I built it into the module. The option to have a spacer module is ok but it's too time consuming, and for the most part, there will ALWAYS be a space. However, in a few rare cases they'd like to not have it. So I thought I'd do a boolean. It will be set to true as a default, but in the few cases they need to, they could control it and turn it off.

But I read that booleans in email are not advisable.

 

What do you think in this specific case thought?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
New Participant
March 29, 2021

But I read that booleans in email are not advisable.

Where'd you read that? A mktoBoolean just controls 2 string values. It's not inherently advisable nor inadvisable — depends on what you're outputting.

New Participant
April 5, 2021

True. I think what the author means is in the scenario where one would use this to toggle on/off a part of the email, using it to control the "display" value with 'block' / 'hide'. This will not work well across different email clients, thus not have the desired outcome.

SanfordWhiteman
New Participant
April 5, 2021
Yep, but that's no less true if you have the same static style in the HTML.

Booleans can be put to very good use in email templates and this kind of "... heard it was bad..." stuff spreads like wildfire!
New Participant
March 29, 2021

In that case, I would use a local variable number (or string if you prefer) that represent the spacing (padding) in px. You can choose either top- or bottom-padding or both after your preference.

I say local variable as you can use the same variable for all your modules if you set the scope (mktoModuleScope) to true.

 

Edit: For the toggle / boolean, it depends on how you can implement it. But using "display" is not a good option as it will not work across all email clients. So to make sure you have a solution that works everywhere - and to increase the flexibility, I would go with the solution above.

noahananAuthor
New Participant
March 29, 2021

Maybe I could do a list? And it would be zero or 20? Would that work?

The goal is to give as little freedom as possible.

New Participant
March 29, 2021

In the case where you want to decrease the flexibility, I think a list could be a good option.