TYPO3 6.2 LTS 使用 FAL 和 TCA

TYPO3 6.2 LTS using FAL and TCA

我有以下问题,我相信你们中的一些人会把这个问题标记为重复,但我找不到针对我的问题的具体答案。

我有一个扩展,我想使用 FAL 添加图像/pdf 等。

根据教程,我必须配置 TCA。好吧,文档是关于这一点的,教程是基于 TCA 的知识。

我还必须使用一些 TypoScript,目前我还没有使用过。

好的,就我的问题而言: 我在哪里编辑 TCA? 我有一个名为 ext_tables 的文件,我可以在其中看到 $GLOBALS['TCA']。 我还有一个目录 TCA,里面有一些文件(只填充了 $GLOBALES['TCA'].

然后,我该如何访问这些数据?我需要在modal里面建一棵树(pop-up也是可以的)

我知道这些问题听起来非常简单,但我找不到可以解释任何内容的教程。

感谢所有帮助:)

非常感谢。

你的问题含糊不清:

到目前为止你到底尝试了什么?

您更改了哪些文件?

您是否需要 FLUIDTEMPLATE、extbase 控制器或其他地方的文件?


将 FAL 字段添加到您的扩展程序的步骤

扩展数据库(typo3conf/ext/yourExtFolder/ext_tables.sql):

CREATE TABLE your_database_table (   
    your_fal_field int(11) unsigned DEFAULT '0' NOT NULL  
)

延长 TCA:

如果您从另一个扩展扩展现有的 table,您可以在 typo3conf/ext/yourExtFolder/Configuration/TCA/Overrides/your_database_table.php

中扩展 TCA

示例(扩展 tt_content):

$newColumn = [
    'field_name' => [
        'image' => [                
            'label'   => 'Image',
            'config'  => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('image', [
               'appearance' => [
                    'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference',
                ],
                'minitems'   => 0,
                'maxitems'   => 1,
            ], $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),
        ],
   ],
];
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $newColumn);

如果您将字段添加到您自己的扩展中,则必须扩展 typo3conf/ext/yourExtFolder/Configuration/TCA/your_database_table.php。 示例(来自 TYPO3 核心 be_users TCA - 缩短版):

return [
    'ctrl' => [
        'label' => 'username',
        'descriptionColumn' => 'description',
    ],
    'columns' => [
        'username' => [
            'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:be_users.username',
            'config' => [
                'type' => 'input',
                'size' => 20,
                'max' => 50,
                'eval' => 'nospace,trim,lower,unique,required',
                'autocomplete' => false,
            ]
        ],
        'avatar' => [
            'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:be_users.avatar',
            'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                'avatar',
                ['maxitems' => 1],
                $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
            )
        ],
    ],
    // Removed more `columns`, `types` and `palettes` config         
];

重要的部分是 avatar 的定义,它使用了 getFileFieldTCAConfig 函数。

扩展您的 extbase 模型 (typo3conf/ext/yourExtFolder/Classes/Domain/Model/YourClass.php)

来自 keinerweiss.de:

的简化片段
class YourClass extends TheModelYouWantToExtend or \TYPO3\CMS\Extbase\DomainObject\AbstractEntity  {
    // ...

    /**
     * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
     */
    protected $yourField;

    /**
     * Returns the image
     *
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
     */
    public function getYourField() {
            return $this->yourField;
    }

    /**
     * Sets the image
     *
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image
     * @return void
     */
    public function setYourField($image) {
            $this->yourField = $yourField;
    }       
}

在 Fluid 中使用您的图像(来自 t3-developer.com):

<f:for each="{mymodel.mypictures}" as="picture">    
    <f:image src="{mypicture.image.uid}" alt="" treatIdAsReference="TRUE" /> 
</f:for>

更多链接(英文):

https://gist.github.com/maddy2101/5668835

http://blog.scwebs.in/typo3/typo3-fal-file-abstraction-layer-in-extbasefluid-extension

更多链接(德语):

http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html

http://t3-developer.com/ext-programmierung/techniken-in-extensions/fal-in-typo3-extensions-verwenden/

http://t3g.at/extbase-bilder-fal-in-extension-integrieren/