首页 文章

如何在自己的extbase扩展中映射tt_content?

提问于
浏览
0

我有一个模型,它具有一些属性和我在同一扩展中的第二个模型的1:1关系,我想将第二个模型完全映射到tt_content . 所以用户可以将tt_content对象插入到我的第一个模型中 .

BE中没有问题 . 我可以插入第一个模型中的对象,在那里我可以插入一个tt_content对象 . 在数据库中我的第一个模型得到了“内容”列,其中tt_content对象的uid所以我认为一切都是正确的...

但是后来控制器...我什么也没得到......只是“内容”属性上的NULL值...

这是我测试“内容”属性的方式:

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

它只返回“NULL”

aaaaa和这里有一些关于第一个模型whitch包含tt_content对象的信息:

第一种模式:

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;
    }

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

第二种模式:

class Tx_PlusbSlidingcontent_Domain_Model_Content extends Tx_Extbase_DomainObject_AbstractEntity {

}

第一个模型的TCA中的“内容”部分:

'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
            ),
        ),
    ),

在TS设置中,我在“持久性”中添加了这个:

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

我只是不知道该配置中的错误在哪里...不是存储库/模型/任何东西必须使用第二个模型的对象自动填充第一个模型上的内容属性?至少一个空的?

2 回答

  • 0

    (在问题编辑中由OP回答 . 转换为社区维基答案 . 请参阅Question with no answers, but issue solved in the comments (or extended in chat)

    OP写道:

    好的神秘解决了...... extension_builder添加了一个名为“ext_typoscript_setup.txt”的文件 . 在那个文件中有for tt_content致命的“recordType”定义......删除了那个并且瞧......一切正常

  • 0

    是的,它非常容易在您的扩展中集成tt_content字段 .

    如果要在tt_content记录中设置第二个 Headers 字段,则必须在ext_table.php中设置以下脚本

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

    然后你必须加载tt_content TCA文件

    #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");
    

    以下字段将用户进行特殊扩展,然后使用以下脚本 .

    $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";
    

    有关这方面的更多信息,请访问

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

相关问题