[TYPO3-mvc] Relations between to models mapped on foreign tables

Gianluca Strafella gianluca.strafella at webformat.com
Tue Oct 22 08:45:03 CEST 2013


Hi,
I think you cannot extend "normally" a model based on a table as 
sys_template that hasn't a TCA configuration.
You can try to create a TCA file in Configuration\TCA of your extention 
about the model Tx_Blatest_Domain_Model_Template, and include it in 
ext_tables.php file. You can see if it works or not.
Otherwise you can retrieve all pages (instances of 
Tx_Blatest_Domain_Model_Subsite) with SubsiteRepository and, later, 
retrieve all Template records by TemplateRepository, for each 
Tx_Blatest_Domain_Model_Subsite.

Regards,
Gianluca


Gianluca Strafella

Software Developer
gianluca.strafella at webformat.com
Tel.   +39-0427-926.389

WEBFORMAT srl – www.webformat.com
Via Mecenate, 76 - 20138 MILANO
Corte Europa, 12 - 33097 SPILIMBERGO (PN)


Il 17/10/2013 19:39, Beta Patch ha scritto:
> 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