Kai
Kai

Reputation: 53

How to map tt_content in own extbase extension?

i got one model that has some properties and a 1:1 relation to my second model in the same extension and i wanted to map that second model completely to tt_content. so the user can insert a tt_content object into my first model.

No Problem in the BE. I can insert objects from the first model and in there i can insert a tt_content object. In the Database my first model got that "content" column where the uid of the tt_content object so i thought everything is correct...

But then to the Controller... i just get nothing... just a NULL value on the "content" property...

this is how i tested the "content" property:

$contentBoxes = $this->contentBoxRepository->findAll();
print(gettype($contentBoxes->current()->getContent()));

and it returns just "NULL"

aaaaaand here are some infos about that first model whitch contains the tt_content object:

First Model:

class Tx_PlusbSlidingcontent_Domain_Model_ContentBox extends Tx_Extbase_DomainObject_AbstractEntity {

    /**
     * Content
     *
     * @var Tx_PlusbSlidingcontent_Domain_Model_Content
     */
    protected $content;

...........

    /**
     * Returns the content
     *
     * @return Tx_PlusbSlidingcontent_Domain_Model_Content $content
     */
    public function getContent() {
        return $this->content;
    }

    /**
     * Sets the content
     *
     * @param Tx_PlusbSlidingcontent_Domain_Model_Content $content
     * @return void
     */
    public function setContent(Tx_PlusbSlidingcontent_Domain_Model_Content $content) {
        $this->content = $content;
    }

...............
}

Second Model:

class Tx_PlusbSlidingcontent_Domain_Model_Content extends Tx_Extbase_DomainObject_AbstractEntity {

}

The "content" section in the TCA of the first Model:

    'content' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:plusb_slidingcontent/Resources/Private/Language/locallang_db.xml:tx_plusbslidingcontent_domain_model_contentbox.content',
        'config' => array(
            'type' => 'inline',
            'foreign_table' => 'tt_content',
            'minitems' => 0,
            'maxitems' => 1,
            'appearance' => array(
                'collapseAll' => 0,
                'levelLinksPosition' => 'top',
                'showSynchronizationLink' => 1,
                'showPossibleLocalizationRecords' => 1,
                'showAllLocalizationLink' => 1
            ),
        ),
    ),

And in the TS Setup i added this in "persistence":

classes {
         Tx_PlusbSlidingcontent_Domain_Model_Content {
             mapping {
                 tableName = tt_content
                 columns {
                 }
             }
         }
     }

i just don't know where the error is in that config... doesn't the repository/model/anything have to autofill the content property on the first model with an object of the second model? at least an empty one?

Upvotes: 1

Views: 3447

Answers (2)

Jainish
Jainish

Reputation: 149

Yes its very easy to integrate tt_content field in your extension.

If you want to set second title field in your tt_content record then you have to set following script in your ext_table.php

$tempColumns = array(
    'subtitle' => array(
        'exclude' => 0,
        'label' => 'title2',
        'config' => array(
            'type' => 'input'
        )
    )
);

Then you have to load tt_content TCA file

#This is for EXTBASE Extension
\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_content');

OR

#This is for PI Base Extension
t3lib_div::loadTCA("tx_dam_cat");

Following field will user for PARTICULAR EXTENSION then use following script.

$TCA["tt_content"]["types"]["list"]["subtypes_excludelist"]["abc_pqr"]="layout,select_key,pages";
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"]["abc_pqr"]="subtitle;;;;1-1-1";

For more information about this then visit

https://jainishsenjaliya.wordpress.com/2014/08/25/how-to-use-tt_content-fields-in-custom-plugin-of-typo3/

Upvotes: 0

(Answered by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

okay mystery solved...

the extension_builder adds a file called "ext_typoscript_setup.txt". In that file there is the for tt_content deadly "recordType" definition... removed that and voila... everything worked

Upvotes: 0

Related Questions