Hopefully, someone knows how I can simplify the following TypoScript so I can pass a list of page ids from the template constant to the template script. say, I have defined a TEASER_IDS = 6,7,9,12,4, and the TypeScript walks thru that list and uses it for the select.pidInList one after the other instead of having to manually create a CONTENT object in the TypoScript for each ID.
lib.teaser = COA
lib.teaser {
10 = CONTENT
10 {
stdWrap.wrap = <div class="part">|</div>
table = tt_content
select.orderBy = sorting
select.pidInList = 6
select.where = colPos=1
select.languageField = sys_language_uid
}
20 = CONTENT
20 {
stdWrap.wrap = <div class="part">|</div>
table = tt_content
select.orderBy = sorting
select.pidInList = 7
select.where = colPos=1
select.languageField = sys_language_uid
}
}
page.50.30 < lib.teaser
It is TYPO3 version 10.4.8
EDIT: new version but I'd like to have the elements be wrapped each, so it results in
//this is what it should look like
<div class="header">CONTENT ID 6 colPos 1</div>
<div class="text">CONTENT ID 6 colPos 2</div>
<div class="header">CONTENT ID 7 colPos 1</div>
<div class="text">CONTENT ID 7 colPos 2</div>
<div class="header">CONTENT ID 4 colPos 1</div>
<div class="text">CONTENT ID 4 colPos 2</div>
TypoScript now:
lib.teaser = COA
lib.teaser {
10 = CONTENT
10 {
stdWrap.wrap = <div class="header">|</div>
table = tt_content
select.orderBy = sorting
select.pidInList = 6,7,4
select.where = colPos=1
select.languageField = sys_language_uid
}
20 = CONTENT
20 {
stdWrap.wrap = <div class="text">|</div>
table = tt_content
select.orderBy = sorting
select.pidInList = 6,7,4
select.where = colPos=2
select.languageField = sys_language_uid
}
}
page.50.30 < lib.teaser
The code gives me, which makes sense, but I have no idea how to change the code so it gives me the preferred output like mentioned above the new code
//this is not what i want
<div class="header">
CONTENT ID 6 colPos 1
CONTENT ID 7 colPos 1
CONTENT ID 4 colPos 1
</div>
<div class="text">
CONTENT ID 6 colPos 2
CONTENT ID 7 colPos 2
CONTENT ID 4 colPos 2
</div>
Do not use two CONTENT objects as they both iterate over all matching CEs. Instead, use the option to overwrite the wrap if the colPos has a corresponding value.
( https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/If.html#if )