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>
If you want a loop over the pages where you collect content from different columns you need to build this structure in typoscript.
As you have noticed now you get all content for column 1 from all pages and then all content from column2.
How could you build a loop over the page IDs? we have no
for
loop in typoscript as it is a configuration language and no programming language.That might be possible with a split on the comma separated list of the ids.