[英]TYPO3 6.2 LTS using FAL and TCA
我遇到以下問題,我敢肯定你們中的一些人會將這個問題標記為重復,但是找不到針對我問題的具體答案。
我有一個擴展名,我想使用FAL添加圖像/ pdf等。
根據教程,我必須配置TCA。 好吧,文檔是關於這一點的。教程基於TCA的知識。
我還必須使用一些TypoScript,到目前為止我還沒有使用過。
好的,據我所知,這是我的問題:在哪里可以編輯TCA? 我有一個名為ext_tables
的文件,在其中可以看到$GLOBALS['TCA']
。 我還有一個目錄TCA,其中包含一些文件(僅填充$GLOBALES['TCA']
。
之后,我該如何訪問這些數據? 我需要在模式內部構建一棵樹(也可以彈出窗口)
我知道這些問題聽起來非常簡單,但我找不到一個可以解釋所有內容的教程。
我感謝所有幫助:)
非常感謝。
您的問題是模糊的國王:
到目前為止,您到底嘗試了什么?
您更改了哪些文件?
您是否需要FLUIDTEMPLATE內部,extbase控制器內部或其他位置的文件?
擴展數據庫( typo3conf/ext/yourExtFolder/ext_tables.sql
):
CREATE TABLE your_database_table (
your_fal_field int(11) unsigned DEFAULT '0' NOT NULL
)
擴展TCA:
如果從另一個擴展名擴展現有表,則可以在typo3conf/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
];
重要的部分是使用getFileFieldTCAConfig
函數的avatar
的定義。
擴展您的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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.