[TYPO3-dev] Extbase: Create ObjectStorage from a group of pages

Stephan Schuler Stephan.Schuler at netlogix.de
Wed Oct 8 15:52:18 CEST 2014


Hey there.

As far as I know, mm tables are *not* required to mm relations in general but only in one out of two possible ways.

You configured "type: group; internal_type: db; allowed: pages".
Change this to "type: select; foreign_table: pages".

This will keep your database layout as it is but only creates a slightly different backend experience.

Of course MM tables are the more "pure" database layout. The old extension kickstarter called it "TRUE MM relation" :). Especially when it comes to relations like categories where one stuff_category_mm table is used for relations between categories on the "foreign" side and an arbitrary number of tables on the "local" side, you can easily determine which whatever record is connected to that category just by looking at a single mm table.

But when you expect a small amount of "local" records (like a view hundreds) and an even smaller amount of "foreign" records (like a view dozens), I still prefer going without MM tables. That just requires less "GROUP" statements and gives an even better overview when looking at the single "local" database table on one hand but is almost equally fast on the other.

At the end of the day it's up to you if you go with or without MM tables. But "extbase requires mm tables in general" is just not true.

Regards,


Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



----------------------------
netlogix auf der it-sa 2014:
Jetzt anmelden zum kostenlosen Mobile Device Management-Check
MDM-Check buchen oder Freikarten beanspruchen: http://it-services.netlogix.de/it-sa-2014
----------------------------




netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



-----Ursprüngliche Nachricht-----
Von: typo3-dev-bounces at lists.typo3.org [mailto:typo3-dev-bounces at lists.typo3.org] Im Auftrag von pcworld
Gesendet: Dienstag, 7. Oktober 2014 21:19
An: typo3-dev at lists.typo3.org
Betreff: Re: [TYPO3-dev] Extbase: Create ObjectStorage from a group of pages

> TYPO3 stores it in the model's database column "pages" as a
> comma-separated string of page UIDs.

It turns out that was the issue.
Quote from https://forge.typo3.org/issues/6249:

> extbase currently doesn't support TCA fields of type "group"
> natively. A easy workaround currently is to additionally define a
> "foreign_table" in your columns configuration together with a MM
> relation of course (no comma separated lists).

So I had to create an MM relation (see
http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Group/Index.html#mm
and
http://lbrmedia.net/codebase/Eintrag/extbase-bidirektionale-mm-relation/).
In tx_extension_domain_model_foo I changed "pages" from "varchar(255)"
to "int(11) unsigned", and added the following table:

CREATE TABLE tx_extension_domain_model_foo_mmpages (
        uid_local int(11) NOT NULL auto_increment,
        uid_foreign int(11) DEFAULT '0' NOT NULL,
        sorting int(11) DEFAULT '0' NOT NULL,

        KEY uid_local (uid_local),
        KEY uid_foreign (uid_foreign)
);

And added the following properties to
$GLOBALS['TCA']['tx_extension_domain_model_foo']['columns']['pages']['config']:
'foreign_table' => 'pages', 'MM' => 'tx_extension_domain_model_foo_mmpages'

In model Foo, I just kept
     /**
      * @var
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extension\Domain\Model\Page>
      */
     public $pages;

Seems to work now.
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev


More information about the TYPO3-dev mailing list