IF Conditions with AND and OR operators

Submitting your vote...
Rating: 3.2 of 5. 17 vote(s).
Click the rating bar to rate this item.

First the OR condition ins sample 1

negate is worked out after condition1 and condition2, with a following AND condition. So if is only false, if condition1 and condition2 are false.

It sounds a bit strange, but thats the way it works in typo3

 

Now the chaining of multiple conditions in the 2nd example:

The isTrue and isFalse (and also some others, see tsref) conditions contain a stdWrap, that means that you can use in a isTrue another if and create all the conditions you need ( if you are able to open the bend in your brain afterwards :) ).

 

I think this way all combinations of conditions can be implemented..

 

# Sample 1
# with negate you can combine multiple conditions with OR 
# Shows the cObject if condition1 and condition2 
if {
  value=1
  isLessThan = condition1
  isFalse = condition2 
  negate = 1
}

# Example 2

# Using nested if's
# condition1 AND NOT  (condition2  UND condition3)

if {
  isTrue = condition1
  # default return false
  isFalse = 1
  # if this condition is met, the 1 from isFalse is deleted und isFalse returns true
   
  isFalse.if {
    value = 1
    isLessThan = condition2 
    isFalse = condition3
  }
}

# condition1 UND (condition2  ODER condition3)
if {
  isTrue = condition1
  isPositive = 1
  isPositive.if {
    value=1
    isLessThan = condition2 
    isFalse = condition3
    negate = 1
  }
}

 

This snippet was submitted by Till.



Comments


Fingerprint, 29-01-08 11:44:
Maybe it can be interesting to recall some logic rules :

AND and OR are *distributables* :
NOT (c1 OR c2) <=> (NOT c1) AND (NOT c2)
NOT (c1 AND c2) <=> (NOT c1) OR (NOT c2)

The first of these rules is used in the first sample,
(c1 OR c2) in fact written as NOT (NOT c1 AND NOT c2)

AND and OR are *associatives* :

c1 AND (c2 OR c3) <=> (c1 AND c2) OR (c1 AND c3)
c1 OR (c2 AND c3) <=> (c1 OR c2) AND (c1 OR c3)

This way, a complex expression can be reduced to be written in TS.
Hope it'll be useful.

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

21-Jan-2012 20:22:24
jemmkwc jemmkwc schrieb: MOGWOX , [url=http://prdpuhwzxyrc.com/]prdpuhwzxyrc[/url],...
fe_useradmin form does not save
20-Jan-2012 20:35:32
fsivjktiuld fsivjktiuld schrieb: idCmnv <a href="http://gakbrrkrxhye.com/">gakbrrkrxhye</a>
fe_useradmin form does not save
19-Jan-2012 18:05:25
bvffee bvffee schrieb: jl2vQt , [url=http://xcinvpbclrbm.com/]xcinvpbclrbm[/url],...
External links and shortcuts directly in the menu
Deutsch
Search: