Created
June 17, 2014 14:48
-
-
Save kraftb/96e060bcf1c58f647594 to your computer and use it in GitHub Desktop.
HOWTO: Extend TYPO3/extbase Model with new fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create ext_tables.sql and add new fields as usual | |
2. Create Configuration/TCA/Overrides/tablename.php and extend TCA therein (before: ext_tables.php) | |
3. Add the following lines to your ext_localconf.php. Where the first argument of "registerImplementation" is the model class you would like to extend and the second argument is your own implementation. | |
$extbaseObjectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container'); | |
$extbaseObjectContainer->registerImplementation('Tx_News_Domain_Model_NewsDefault', 'thinkopen_at\T3ff\Domain\Model\NewsT3ff'); | |
4. Create your own implementation of the mode class and add the new properties + getters/setters for them | |
5. Add the following TypoScript: | |
-------------------------------------------- | |
config.tx_extbase.persistence.classes { | |
# Base model | |
Tx_News_Domain_Model_News { | |
subclasses { | |
# Take care to use an unique number | |
# Specify your own model class here | |
3 = thinkopen_at\T3ff\Domain\Model\NewsT3ff | |
} | |
} | |
# Specify a tableName (column) mapping here | |
thinkopen_at\T3ff\Domain\Model\NewsT3ff { | |
mapping { | |
recordType = 0 | |
tableName = tx_news_domain_model_news | |
} | |
} | |
} | |
6. Clear all caches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment