This TypoScript template worked for me on a TYPO3 CMS 6.2.17 server.
page.30 = CONTENT
page.30 {
table = tt_content
select {
orderBy = sorting
where = colPos = 0
}
renderObj = COA
renderObj {
wrap = <div>|</div>
10 = COA
10.10 = TEXT
10.10.if.isTrue.field = header_link
10.10.if.isFalse.field = image
10.10 {
stdWrap.data = header_link
stdWrap.typolink {
parameter.field = header_link
wrap = <img src="|" />
ATagBeforeWrap = 1
}
}
10.20 = TEXT
10.20.if.isFalse.field = header_link
10.20.stdWrap.field = header
10.20.stdWrap.wrap = <h1>|</h1>
}
}
The result displays the tt_content
header
field unless both the header_link
and image
fields test positive. Here are the relevant fields of the tt_content
records I used in the test. (The || indicates an empty field value.)
uid|hidden|Sorting|CType|header|image|deleted|colPos|header_link|
29|0|256|text|Regular text element|NULL|0|0||
30|0|512|image|Image element|0|0|0|file:37|
31|0|384|image|Image element with no image|0|0|0||
32|0|768|div|Divider|NULL|0|0||
I include the hidden
and deleted
columns as a reminder, because if either are set to 1
, the CONTENT select
function will not return that record for renderObj to use. There are also checks for start and end date, and whether the current user has access privileges to the content element. See "select" in the TypoScript Reference manual.
Multiple TypoScript if
statements on an object are joined together with an implicit logical AND. See the "if" page in the TypoScript Reference and its "more complex" example having two conditions under "Explanation".
Here is the if
logic involved in this test.
Object page.30.renderObj.10.10.
uid|header_link|if.isTrue.field = header_link|image|if.isFalse.field = image|Result
29||no|NULL|no|not rendered
30|file:37|yes|0|yes|rendered
31||no|0|yes|not rendered
32||no|NULL|no|not rendered
Object page.30.renderObj.10.20.
uid|header_link|if.isFalse.field = header_link|Result
29||yes|rendered
30|file:37|no|not rendered
31||yes|rendered
32||yes|rendered
The output display yields the same result if we use only the if.isTrue.field = header_link
test on for the page.30.renderObj.10.10
object, and leave off the if.isFalse.field = image
test. However, keeping the if.isFalse.field = image
test more closely answers the request, and illustrates checking multiple fields.