你的问题是模糊之王:
到目前为止,您到底尝试了什么?
你改了哪些文件?
您是否需要 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/