Conditional Variables
Posted: 03 September 2010 07:03 PM   [ Ignore ]
Wallflower
Rank
Total Posts:  5
Joined  2010-04-10

Would be great if more of the variables from tags were available for use in conditionals.

For example in the {exp:cartthrob:cart_info} tag there’s a {total_items} variable.  Would be nice to be able to do something like this:

You have {total_items} {if total_items == 1}item{if:else}items{/if} in your cart

Apologies if this has been asked before, a cursory search through the forums showed nothing.

Jamie

Profile
 
 
Posted: 03 September 2010 07:43 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  7452
Joined  2008-09-29

Use

{if "{total_items}" 
 Signature 

NOTE: If I say “I will look into x” and you PM me information, please do not hesitate to contact me again about it, if I do not respond in several hours, or at most a day. Please feel free to remind me as you see fit

Profile
 
 
Posted: 03 September 2010 07:57 PM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  5
Joined  2010-04-10

Yes, I know that works too.  But that always seems like a bit of a hack.  smile  And in some cases that won’t work.  Like if there were a quote in the value, though in this case we are safe from that of course.

Profile
 
 
Posted: 03 September 2010 10:55 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  7452
Joined  2008-09-29

But that always seems like a bit of a hack.

It’s a bit inelegant maybe, but not much of a hack. To your point though, it’s the kind of polish we’d eventually like to provide. I’m committed to refining CT… so maybe after the heats off for the next release.

 Signature 

NOTE: If I say “I will look into x” and you PM me information, please do not hesitate to contact me again about it, if I do not respond in several hours, or at most a day. Please feel free to remind me as you see fit

Profile