Home > Back-end >  How can I get the value from two records in a content element in TYPO3?
How can I get the value from two records in a content element in TYPO3?

Time:06-21

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.

CodePudding user response:

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.

CodePudding user response:

I can't be sure as you have not provided your TCA and SQL declaration, but I assume you accessed the record with the uid, that is the count of relations.

TYPO3 inserts a field with the count of records, where the record relation is stored either in the related record (as a back link) or in mm-records.

  • Related