Search code examples
databasetypo3typoscript

How can I get the value from two records in a content element in TYPO3?


I created a content element in TYPO3 (Ver. 11.5.9). Now I want to finish my HTML-files with Fluid. But I can't display my data from my table of a database.

The Backend of the content element seems like so: enter image description here

In a content element there are two tabs and in every tab I can add some child items.

My table in a database is so:

  • tt_content
  • tx_anreisetag_item (this is a table for a tab of Anreisetag)
  • tx_abreisetag_item (this is a table for a tab of Abreisetag)

The data of the child items are saved in the tablestx_anreisetag_item and tx_abreisetag_item.

I added three records in Anreisetag and two records in Abreisetag. But if I check a debug in the frontend, then I can see just two records of Abreisetag. I can't find no object of Anreisetag: enter image description here

In typoscript I wrote this codes:

tt_content.klassenfahrt_anundabreisetag >
tt_content.klassenfahrt_anundabreisetag =< lib.contentElement
tt_content.klassenfahrt_anundabreisetag {
templateName = AnundAbreisetag
    dataProcessing {
        20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        20 {
            table = tx_anreisetag_item
            pidInList.field = pid
            where {
                data = field:uid
                intval = 1
                wrap = tt_content=|
            }
            orderBy = sorting
        }
        

        30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        30 {
            table = tx_abreisetag_item
            pidInList.field = pid
            where {
                data = field:uid
                intval = 1
                wrap = tt_content=|
            }
            orderBy = sorting
        }  

        40 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        40 {
            references.fieldName = tx_anreisetag_image
            as = imageAnreise
         } 
         50 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
         50 {
            references.fieldName = tx_abreisetag_image
            as = imageAbreise
         } 

      }
}

How can I register my another records of Anreisetag?

I hope someone can help me. Thank you.


Solution

  • You need to tell the DatabaseQueryProcessor the name of the records. If you don't add

    as = abreisetag
    

    and also for the other call, both queries are stored in the variable named records. Then the first query will be overwritten by the second query.

    Small hint: Use english variables.