[TYPO3-dev] Extbase: Create ObjectStorage from a group of pages
pcworld
0188801 at googlemail.com
Tue Oct 7 21:19:27 CEST 2014
> 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.
More information about the TYPO3-dev
mailing list