Hallo Leute,
ich versuche, in einer Extension (für Reiseberichte) Inhalte als tt_content-Elemente einzubinden. Habe dazu ein Model "Content" erzeugt und mappe das auf tt_content. Im Backend funktioniert das ganze auch. Ich kann die Inhalte per IRRE anlegen. Die Uids der Reiseberichte werden auch korrekt in tt_content abgespeichert und im Reisebericht steht auch die richtig Anzahl der zugehörigen Content-Elemente.
Das Problem ist, dass ich keinen Zugriff im FE-Plugin habe. Dort wird mir beim Debuggen der inhalte-Eigenschaft nur ein leeres ObjectStorage ausgegeben.
Habe in der Reisebericht Klasse die Eigenschaft angelegt und entsprechende Getter/Setter:
/**
* Inhalte
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content>
* @cascade remove
*/
protected $inhalte = null;
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getInhalte(){
return $this->inhalte;
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $inhalte
*/
public function setInhalte($inhalte){
$this->inhalte = $inhalte;
}
/**
* Adds a Content
*
* @param \SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content $inhalt
*/
public function addInhalt(\SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content $inhalt){
$this->inhalte->attach($inhalt);
}
/**
* Removes a Content
*
* @param \SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content $inhaltToRemove
* @return void
*/
public function removeInhalt(\SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content $inhaltToRemove){
$this->inhalte->detach($inhaltToRemove);
}
/**
* __construct
*/
public function __construct(){
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects(){
$this->inhalte = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
Im TS-Setup habe ich das mapping so vorgenommen:
plugin.tx_sgeducataidreiseberichte_pi1 {
view {
templateRootPaths.0 = {$plugin.tx_sgeducataidreiseberichte_pi1.view.templateRootPath}
partialRootPaths.0 = {$plugin.tx_sgeducataidreiseberichte_pi1.view.partialRootPath}
layoutRootPaths.0 = {$plugin.tx_sgeducataidreiseberichte_pi1.view.layoutRootPath}
}
persistence {
storagePid = {$plugin.tx_sgeducataidreiseberichte_pi1.persistence.storagePid}
classes {
SGMultimedia\SgEducataidreiseberichte\Domain\Model\Content{
mapping{
tableName = tt_content
columns {
uid.mapOnProperty = uid
}
}
}
}
}
}
Was muss ich noch tun, um auch im Plugin an die Inhalte zu kommen?