Task at our web agency: We need a content element that automatically displays all sections, i.e. the content headings of the elements assigned to a news record. This element already exists for regular pages, but here we need to use the tx_news_related_news column, which references an entry in the tx_news_domain_model_news table for each content element.
We therefore use the DatabaseQueryProcessor in the setup (setup.typoscript) of the respective extension:
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_content
orderBy = sorting
where = tx_news_related_news = ###news_record_id### AND sectionIndex = 1
pidInList=pid
as = myrecords
markers {
news_record_id.data = GP:tx_news_pi1|news
}
}
This allows us to loop through the "myrecords" and, for example, output the respective headers.
It becomes somewhat more difficult if a created translation uses the default language, meaning that the parent column in tx_news_domain_model_news contains a "0" and the language is neither "0" nor "-1". In this case, we can use the t3orig_uid, which contains the ID of the parent element, and then search for it in tt_content using a nested DatabaseQueryProcessor statement (Nested DatabaseQueryProcessor / Data Processing):
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
table = tx_news_domain_model_news
where = uid = ###news_record_id### AND l10n_parent = 0 AND sys_language_uid > 0
pidInList=pid
as = myrecords-wo-standard-lang
markers {
news_record_id.data = GP:tx_news_pi1|news
}
dataProcessing {
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
table = tt_content
pidInList=pid
where.dataWrap = tx_news_related_news = {field:t3_origuid}
as = myrecords-wo-standard-lang-contents
}
}
}
That's it! Spotted at our agency on a TYPO3 website running TYPO3 v10.
