Categories > TinyButStrong general >

if statement AND condition?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Beta2K
Date: 2010-01-29
Time: 17:32

if statement AND condition?

Is there a AND for the if statement at all?  Or can I only use if on one condition at a time and need to next them to have more then one condition?

Thanks,

Jason Stahls
By: TomH
Date: 2010-01-29
Time: 20:31

Re: if statement AND condition?

By: Beta2K
Date: 2010-02-01
Time: 15:53

Re: if statement AND condition?

No I didn't...  I've looked at them now and I'm still a little confused on how to pull it off.  Do both AND'd conditions have to use the same operator?  Eg, can this be done? if ($a == 'a') && ($b > 0)  I'm trying to use TBS to pull generic descriptions from a database then populate them with vendor/manufacture names ect and display it.  Unfortunately some of the conditions to determine the details of a item are kinda complex :(
By: TomH
Date: 2010-02-01
Time: 16:48

Re: if statement AND condition?

I'd have to test your case to find out if that wqorks myself ;)

FWIW, when things seem to be getting complex in my TBS blocks...  I find that there are two things that I should have been thinking about:
(1) using my PHP code to build better, more complete sql queries and subqueries - since it's easier to get MySql to do the heavy lifting (and I also learn a lot of neat things in query land)
(2) using TBS event functions to do the PHP testing of conditions in the function and building new block variable to use inside the block.

Sorry that doesn't directly answer your question,
By: Beta2K
Date: 2010-02-01
Time: 17:23

Re: if statement AND condition?

I'd love to be doing this on the SQL side I'm just being pushed by higher ups to do it this way...  They want a minimal number of templates that apply to as many things as possible, even tho I'm taking more time to code it then it would to have made more templates :)  Ah well.

I'll look into the event functions and see if I can do it that way.  If you find anything out about mixing operators that would be great :)

Thanks,

Jason
By: Beta2K
Date: 2010-02-01
Time: 17:30

Re: if statement AND condition?

Just for everyone to see, these are the couple blocks I've come up with trying to address the same issue.

[onshow.discontinu; if [val]>0; then [onload.quantity; if [val]+-0; then 'This [var.category] (SKU: [var.sku]) by [var.manu] has been discontinued but Park''s still has stock!  Hurry now before they're gone!'; else 'Park''s only has [var.quantity] of these excelent [var.category]''s by [var.manu] hurry in before they''re gone']; else 'This [var.category] by [var.manu] is a regular item here at Park''s with approx. [var.quantity] in stock (Please call to confirm)']

[onshow;block=begin; when [onload.discontinu]=1][onload; block=begin; when [onload.quantity]+-0]This [onload.category] (SKU: [onload.sku]) by [onload.manu] has been discontinued but Park's still has stock!  Hurry now before they're gone![onload;block=end][onshow;block=end][onshow;block=begin; when [onshow.discontinu]==0][onload; block=begin; when [onload.quantity]-+5]Park's only has [onload.quantity] of these excelent [onload.category]'s by [onload.manu] hurry in before they're gone.[onload;block=end][onshow; block=end][onload;block=begin;when [onload.quantity] +=- '5']This [onload.category] by [onload.manu] is a regular item here at Park's with approx. [onload.quantity] in stock[onload;block=end]

[onshow; if [var.discontinu]-[var.quantity]+-0-0; then 'This [var.category] (SKU: [var.sku]) by [var.manu] has been discontinued but Park''s still has stock!  Hurry now before they're gone!'; else 'This [var.category] by [var.manu] has been discontinued, please check with Park''s for stock' ] [onload; if [var.discontinu]==0; then 'This [var.category] by [var.manu] is a regular item here at Park''s with approx. [var.quantity] in stock']

[onshow; if '[var.discontinu]-[var.quantity]'+-'0-0'; then 'This [var.category] (SKU: [var.sku]) by [var.manu] has been discontinued but Park''s still has stock!  Hurry now before they''re gone!'; else 'This [var.category] by [var.manu] has been discontinued, please check with Park''s for stock' ] [onload; if [var.discontinu]==0; then 'This [var.category] by [var.manu] is a regular item here at Park''s with approx. [var.quantity] in stock']