[TYPO3-mvc] Various object types depending on the "type" field

Sebastian Kurfürst sebastian at typo3.org
Tue Feb 22 14:14:59 CET 2011


Hey Dmitry,

> Imagine the following "typical TYPO3" issue. You have a table with a
> "type" field, which means you store different data in the same table and
> handle it accordingly to the "type" field value.

Extbase supports Single Table Inheritance for this use-case, which is
configured through TypoScript. Here follows an example for the blog example:

> plugin.tx_blogexample.persistence.classes {
> 	Tx_Extbase_Domain_Model_FrontendUser.subclasses {
> 		Tx_BlogExample_Domain_Model_Administrator = Tx_BlogExample_Domain_Model_Administrator
> 	}
> 	Tx_BlogExample_Domain_Model_Administrator {
> 		mapping {
> 			tableName = fe_users
> 			recordType = Tx_BlogExample_Domain_Model_Administrator
> 		}
> 	}
> }
So, you have to configure three things:
1) Configure the type column in TCA correctly (not shown here)
2) Tell the system that if you ask for the Parent class (in this case
"Frontend User"), it should also return records of the subclasses.
That's why the subclasses need to be registered in the parent class.

3) Tell the concrete class to be loaded from a different table
(tableName=...), and to be of a certain recordType -- this is the value
which is expected in the "type"-Field.

Hope this helps :-)

Greets,
Sebastian
PS: I'll be offline for the next three weeks, but I am sure many others
will continue answering questions here ;)


More information about the TYPO3-project-typo3v4mvc mailing list