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

pcworld 0188801 at googlemail.com
Tue Oct 7 15:42:45 CEST 2014


Hi all,

I have a model Foo with a property "pages", so the user can create a
record of type "Foo" and select pages to use with the record. TYPO3
stores it in the model's database column "pages" as a comma-separated
string of page UIDs.
Foo's TCA:

$GLOBALS['TCA']['tx_masterpages_domain_model_foo'] = array(
	// snip
	'columns' => array(
		'pages' => array(
			'label' => 'Select pages',
			'config' => array(
				'type' => 'group',
				'internal_type' => 'db',
				'allowed' => 'pages',
				'show_thumbs' => 1,
				'maxitems' => 999,
			),
		)
	)
);

I also have a model "Page" that maps to the "pages" table (I took it
from the pw_teaser extension).
How can I get TYPO3 to let Foo's property "pages" be an ObjectStorage of
Page instances (instead of just the comma-separated string)?

Basically what I want in my model is a property of this type:
	/**
	 * @var 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extension\Domain\Model\Page>
	 */
	public $pages;

What's the cleanest solution to this (it doesn't look like TYPO3
automatically handles this, I just get an empty ObjectStorage)?

I could keep $pages as a string, and then invoke a method to explode()
the string, create Page objects and store them in an array in a
different property. That doesn't sound very straightforward though.

Thanks!



More information about the TYPO3-dev mailing list