I want to extend sys_file_reference with a own field. So i created the field and the TCA. In the backend the field is usable, but i cant refer to the field in my fluid template.
ext_tables.php:
CREATE TABLE sys_file_reference (
nofollow int(11) DEFAULT '0' NOT NULL,
);
Configuration/TCA/Overrides/sys_file_reference.php:
$tempColumns = array(
'nofollow' => array(
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'Link als Nofollow?',
'config' => array(
'type' => 'check',
'default' => '0'
)
)
);
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_reference',$tempColumns,1);
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('sys_file_reference', 'imageoverlayPalette','--linebreak--,nofollow','after:description');
As far it works in the backend.
Classes/Domain/Model/MyFileReference.php
<?php
namespace LISARDO\Foerderland\Domain\Model;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
class MyFileReference extends FileReference {
/**
* nofollow
*
* @var integer
*/
protected $nofollow;
/**
* Returns the nofollow
*
* @return integer $nofollow
*/
public function getNofollow() {
return $this->nofollow;
}
/**
* Sets the nofollow
*
* @param integer $nofollow
* @return void
*/
public function setNofollow($nofollow) {
$this->nofollow = $nofollow;
}
}
in my setup:
config.tx_extbase.persistence.classes {
LISARDO\Foerderland\Domain\Model\MyFileReference {
mapping {
tableName = sys_file_reference
}
}
}
In Fluid i get image.uid oder image.link but image.nofollow is always empty. What did i wrong? I presume the mapping is not correct ...
Well i got the right answer and noticed that i made a mistake and explained it wrong in some ways. First: it is not a normal extbase extension but simply a own content element. So i do not have a own model for my extension where i can inject the implementation as Georg and Victor proposed. I simply had to change the syntax in fluid: {image.properties.nofollow} does the job.
And i recognized that i dont need most of my code:
Classes/Domain/Model/MyFileReference.php
is not necessaryconfig.tx_extbase.persistence.classes
is not necessary too
Only the TCA-Code is needed and a different syntax in fluid.
But i cant figure out why this syntax works and the normal syntax dont.
Thanks for all answers!