[TYPO3] 'if' problem

Ernesto Baschny [cron IT] ernst at cron-it.de
Mon Jan 30 11:54:50 CET 2006


John Angel schrieb am 30.01.2006 11:41:

> 'if' clause is making me problems...
> 
> The code below should display just the name if email doesn't exist. But,
> it always displays email anchor. Please help.
> 
> # Render author & email
> lib.author = TEXT
> lib.author {
> dataWrap = page:author
> 
> # ALWAYS WORKS!?
> if.isTrue.data = page:author_email
>  dataWrap = <A href="mailto:{page:author_email}">{page:author}</A>
> if >
> }

You don't have control structures in TypoScript, just one huge array of
properties. "if" is no control construct, its just another property of
the stdWrap function (for the TEXT object, in this case).

So this "if" applies to the TEXT element.

  if.isTrue.data = page:author_email
  dataWrap = <A href="mailto:{page:author_email}">{page:author}</A>
  if >

is the same as

  if.isTrue.data = page:author_email
  if >
  dataWrap = <A href="mailto:{page:author_email}">{page:author}</A>

because order doesn't matter on those named properties. You see that
your "if" is deleted and never applies. Most "if/else" constructs can be
emulated by a COA with two elements:

lib.author = COA
lib.author {
  # Case when there is no Email
  10 = TEXT
  10.data = page:author
  10.if.isFalse.data = page:author_email

  # Case when there is an Email
  20 = TEXT
  20.if.isTrue.data = page:author_email
  20.data = page:author
  20.dataWrap = <a href="mailto:{page:author_email}">|</a>
}

and there might be other ways to do that in TS.


Grrets,
Ernesto



More information about the TYPO3-english mailing list