Hi,
Ich bin gerade an meinem ersten Extbase Projekt. Ich habe Project Datensätze, die tt_content Elemente enthalten. So weit so gut. Da man Core-Tabellen wie tt_content im EXT:extension_kickstarter nicht mit eigenen Tabellen verbinden kann, habe ich erst mal eine Dummy Tabelle "content" im Extbase Kickstarter angelegt und diese mit dem Projekt verbunden und dann im TCA und Typoscript die Tabelle meines Content-Models wieder auf tt_content geändert. Im Backend kann man problemlos tt_content Elemente über IRRE dem Projekt zuordnen. Aber wenn ich die Content Elemente im Fluid-Template ausgeben will, behauptet das Projekt Model, es hätte keine Content-Elemente in seinem ObjectStorage.
Classes/Domain/Model/Project.php:
class Tx_Nhb_Domain_Model_Project extends
Tx_Extbase_DomainObject_AbstractEntity {
...
/**
* Content
*
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_Nhb_Domain_Model_Content> $content
*/
protected $content;
...
/**
* Returns the content
*
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_Nhb_Domain_Model_Content> $content
*/
public function getContent() {
return $this->content;
}
...
}
Classes/Domain/Model/Content.php:
class Tx_Nhb_Domain_Model_Content extends Tx_Extbase_DomainObject_AbstractValueObject {
/**
* __construct
*
* @return void
*/
public function __construct() {
}
}
Typoscript:
plugin.tx_nhb {
persistence {
classes {
Tx_Nhb_Domain_Model_Content {
mapping {
tableName = tt_content
recordType = Tx_Nhb_Domain_Model_Content
columns {
}
}
}
}
}
}
TCA:
$TCA['tx_nhb_domain_model_project'] = array(
...
'columns' => array(
...
'content' => array(
'exclude' => 0,
'label' => 'LLL:EXT:nhb/Resources/Private/Language/locallang_db.xml:tx_nhb_domain_model_project.content',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tt_content',
'foreign_field' => 'project',
'maxitems' => 9999,
'appearance' => array(
'collapse' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
),
),
),
...
),
);
SQL:
CREATE TABLE tt_content (
project int(11) unsigned DEFAULT '0' NOT NULL
);
ext_tables.php:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['project']['config']['type'] = 'passthrough';
$this->content in class Classes/Domain/Model/Project.php ist immer leer, obwohl das Project in der Datenbank 3 tt_content elemente zugeordnet hat.
In mysql steht tx_nhb_domain_model_project.content (id: 1) auf 3 und die zugeordneten tt_content Elemente (ids: 15, 14, 13) haben alle tt_content.project auf 1 stehen. Das ist beides korrekt gespeichert.
In Fluid versuche ich nur mal die uids der Elemente auszugeben:
<f:for each="{project.content}" as="content">
{content.uid}<br />
</f:for>
Eigentlich kann nur eine Kleinigkeit falsch sein, aber ich finde keine Doku für diesen etwas abgefahrenen Fall, die mir das klar macht, was hier falsch sein könnte.