0

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

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

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

我还必须使用一些我到目前为止还没有使用过的 TypoScript。

好的,据我所知,这是我的问题:我在哪里编辑 TCA?我有一个名为ext_tableswhere I can see的文件$GLOBALS['TCA']。我还有一个目录 TCA,里面有一些文件(只用$GLOBALES['TCA'].

之后,我如何访问这些数据?我需要在模态框内部构建一棵树(也可以弹出)

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

我感谢所有帮助:)

非常感谢。

4

1 回答 1

1

你的问题是模糊之王:

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

你改了哪些文件?

您是否需要 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:

如果您从另一个扩展扩展现有表,则您可以在其中扩展 TCAtypo3conf/ext/yourExtFolder/Configuration/TCA/Overrides/your_database_table.php

示例(扩展 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/

于 2017-05-06T19:08:21.190 回答