[TYPO3-mvc] Relations between to models mapped on foreign tables
Beta Patch
betapatch at gmx.net
Thu Oct 17 19:39:59 CEST 2013
Hi there,
i have set up to models with the extension builder.
One called subsite, the other template.
subsite should be mapped on table pages and template on table sys_template.
I configured it to be an 1:n relation.
the ext_typoscript_setup.txt looks like this:
config.tx_extbase {
persistence {
classes {
Tx_Blatest_Domain_Model_Subsite {
mapping {
tableName = pages
columns {
title.mapOnProperty = title
}
}
}
Tx_Blatest_Domain_Model_Template {
mapping {
tableName = sys_template
columns {
title.mapOnProperty = title
constants.mapOnProperty = constants
}
}
}
}
}
}
In the SubsiteContoller I have an Index action. It should echo the titles of all found pages and their templates.
public function indexAction() {
$subsites = $this->subsiteRepository->findAll();
foreach ($subsites as $subsite) {
echo $subsite->getTitle()."<br>\n";
$templates = $subsite->getTemplates();
foreach ($templates as $template) {
echo "<pre>\t".$template->getTitle()."</pre><br>\n";
}
}
}
The Problem is: It does not find any Templates. Do I have to configure the key of the foreign table relation? If so, how?
I'm a bloody beginner in extbase, and it would be great if someone can give me a hint.
More information about the TYPO3-project-typo3v4mvc
mailing list