[TYPO3] TS Conditions

Christopher Torgalson bedlamhotel at gmail.com
Fri Dec 29 21:11:03 CET 2006


Hi,

On 12/29/06, Antonio Willybiro <keiser_soze at hotmail.com> wrote:
> Hi there,
>
> How would you make that statement:
> "If pageid=1 then lib.foo = aaa BUT IF pageid=2 then lib.foo = bbb ELSE
> lib.foo = ccc"


The easy way is like this [1]--if the conditions are mutually exclusive:

[globalVar = TSFE:id=1]
lib.foo = aaa
[globalVar = TSFE:id=1]
lib.foo = bbb
[global]

You could also do the same with 'if' [2] in, for example, a COA, but
it gets to be pretty untidy code pretty quickly:

lib.foo = COA
lib.foo {
  # Output 'foo' if page id = 1
  5 = HTML
  5 {
    value = foo
    value {
      if {
        value = 1
        equals.data = TSFE:id
      }
    }
  }

  # Output 'bar' if page id = 2:
  10 = HTML
  10 {
    value = bar
    value {
      if {
        value = 2
        equals.data = TSFE:id
      }
    }
  }
}

-- 
Christopher Torgalson


[1] http://typo3.org/documentation/document-library/references/doc_core_tsref/4.0.0/view/4/1/
[2] http://typo3.org/documentation/document-library/references/doc_core_tsref/4.0.0/view/5/7/


More information about the TYPO3-english mailing list