I have the following problem and I'm sure some of you will mark this question as duplicate but I couldn't find a specific answer for my problem.
I have an extension and I want to add images / pdf's etc. using the FAL.
According to tutorials I have to config the TCA. Well, the docs are sh.. about that point and the tutorials are based on the knowledge of TCA.
I also have to use some TypoScript, which I haven't used to this point.
Ok, as far as I got here's my question:
Where do I edit the TCA?
I have a file named ext_tables
where I can see $GLOBALS['TCA']
.
I also have a directory TCA with some files in it (only filled with $GLOBALES['TCA']
.
And after that, how do I access these datas? I need to build a tree in the inside of a modal (pop-up is also possible)
I know these questions sound horribly easy but I couldn't find a tutorial which could explain anything at all.
I appreciate all help :)
Thanks a lot.
Your question is king of vague:
What exactly did you try so far?
Which files did you change?
Do you need the files inside your FLUIDTEMPLATE, inside your extbase controller or somewhere else?
Extend the database (typo3conf/ext/yourExtFolder/ext_tables.sql
):
CREATE TABLE your_database_table (
your_fal_field int(11) unsigned DEFAULT '0' NOT NULL
)
Extend the TCA:
If you extend an existing table from another extension you have the extend the TCA inside typo3conf/ext/yourExtFolder/Configuration/TCA/Overrides/your_database_table.php
Example (extend 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);
If you add the field to your own extension your have to extend typo3conf/ext/yourExtFolder/Configuration/TCA/your_database_table.php
.
Example (from TYPO3 core be_users TCA - shortened version):
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
];
The important part is the definition of avatar
which uses the getFileFieldTCAConfig
function.
Extend your extbase model (typo3conf/ext/yourExtFolder/Classes/Domain/Model/YourClass.php
)
Simplified snippet from 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;
}
}
Use your images in Fluid (From t3-developer.com):
<f:for each="{mymodel.mypictures}" as="picture">
<f:image src="{mypicture.image.uid}" alt="" treatIdAsReference="TRUE" />
</f:for>
More links (english):
https://gist.github.com/maddy2101/5668835
http://blog.scwebs.in/typo3/typo3-fal-file-abstraction-layer-in-extbasefluid-extension
More links(german):
http://keinerweiss.de/755-typo3-fal-in-einer-eigenen-extbasefluid-extension-einsetzen.html