TYPO3 inline integration of news in my own extension

53 Views Asked by At

I am using TYPO3 v12.
I want to implement multiple news articles in my own repository.
But somehow in the frontend I can only see the last one I created.
In Backend it looks fine.

Any Ideas?

Model/Pferd
Model/Pferd


TCA
TCA


ext_tables
ext_tables


The Debug Output from the Controller:
The Debug Output from the Controller


Backend: Backend


$pferde = $this->pferdRepository->findeMeinePferde($activeuserid);
foreach ($pferde as $pferd) {
        $termine = $this->newsRepository->findeTermine($pferd->getUid());
        foreach ($termine as $termin) {
                \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($termin);
                $pferd->setNews($termin);
        }    
}
1

There are 1 best solutions below

0
On

In Pferd, you defined the property $news as a nullable object type 'News'.

However, what you want (and have created correctly in the TCA) is an ObjectStorage that can contain several News-objects.

use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Pferd extends AbstractEntity {
    /**
     * @var ObjectStorage<News>
     */
    public $news;

    public function getNews(): ObjectStorage
    {
        return $this->news;
    }

}