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

noahanan
Level 2

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

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

9 REPLIES 9
Peter_Rytter
Level 2

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

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.

Tags (2)
noahanan
Level 2

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

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.

Peter_Rytter
Level 2

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

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

noahanan
Level 2

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

A list of the two options worked and was the easiest thing to implement.

Dave_Roberts
Level 10

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

There's also the "number" string which you can set to have a min and max as well as increment it at any scale.

 

Here's an example preset w/ a default of "10px" which can be incremented by 5px from 0px to 20px [0,5,10,15,20]:

<meta class="mktoNumber" id="paddingBottom" mktoName="Element: Padding Bottom" default="10" min="0" max="20" units="px" step="5">

 This might save you a little time over the list by not having to manually type out all the options. To set this to act like a boolean, you could set the default to 10, the min to 0, the max to 10 and increment by 10. 

 

I think a list sounds like the best choice in your case, but thought I'd mention this as another option if you come across something like this in the future.

 

noahanan
Level 2

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

That's a good way too. For us we wanted exactly 2 options.

SanfordWhiteman
Level 10 - Community Moderator

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


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.

Peter_Rytter
Level 2

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

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
Level 10 - Community Moderator

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

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!