I want to alternate the position of an html element. Unfortunately this is for an html email newsletter, so I need to alter the html on every other post instead of just assigning a different class name. Is this possible?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
December 28, 2010 3:47pm
Subscribe [3]#1 / Dec 28, 2010 3:47pm
I want to alternate the position of an html element. Unfortunately this is for an html email newsletter, so I need to alter the html on every other post instead of just assigning a different class name. Is this possible?
#2 / Dec 28, 2010 6:13pm
Hi Mike,
Yes, you can do that. It should work like this:
{switch='<div class="one">|<div class="two">|<div class="three">'}I did put in a class attribute there, but you can use almost any HTML in the switch statement, though I advise you to keep it simple. I usually do this to insert a clearing <div> after each 3rd item or something like that.
{switch='||<div class="clear"></div>'}Greetz,
Wouter
#3 / Dec 29, 2010 11:17am
Hi Mike,
Yes, you can do that. It should work like this:
{switch='<div class="one">|<div class="two">|<div class="three">'}I did put in a class attribute there, but you can use almost any HTML in the switch statement, though I advise you to keep it simple. I usually do this to insert a clearing <div> after each 3rd item or something like that.
{switch='||<div class="clear"></div>'}Greetz,
Wouter
Thank you!! Your post made sense, but i wasn’t sure it was going to work since the html I was switching wasn’t very simple and had EE tags in it, but it worked! Thanks again!
#4 / Dec 29, 2010 4:02pm
Hi Mike,
Using EE tags in the switch tag is a recipe for headache as you’ll get to deal with parse order and such (though I doubt it gets parsed at all).
If you need an advanced switch statement like it’s used in PHP, you should check out Switchee by Mark Croxton. It’s basically the PHP switch statement wrapped in a plugin, but it is awesome!
Greetz,
Wouter
#5 / Jan 23, 2011 3:31pm
Yeah this kind of technique should work, but I’m getting really strange result here -
using:
{switch='||||<div class="clear"></div>'}Which should parse 4 entries on a row and then to clear the row with div class=clear
I’m getting really strange output here - first row is cleared afer the 4-th entry but then on the second I’ve got clear AFTER the 5-th entry and then another clear after the 6-th entry see my firebug console attached.