I have in my TYPO3 an object called Location where I store informations about a city, including a pdf file.
In the backend I can upload a pdf without problem, but when I try to display it, I get NULL. The value of 'pdf' in the database is not NULL, but when I debug <f:debug>{location}</f:debug>
I get pdf => NULL !!!
Here is my TCA/LOCATION :
$GLOBALS['TCA']['tx_locations_domain_model_location'] = array(
'ctrl' => $GLOBALS['TCA']['tx_locations_domain_model_location']['ctrl'],
....
'columns' => array(
...
'pdf' => array(
'exclude' => 1,
'label' => 'LLL:EXT:locations/Resources/Private/Language/locallang_db.xlf:tx_locations_domain_model_location.pdf',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/pics',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 1
)
),
...
The Getter and Setter should be fine in typo3conf/ext/locations/Classes/Domain/Model/Location.php :
/**
* Returns the pdf
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
*/
public function getPdf() {
return $this->pdf;
}
/**
* Sets the pdf
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
* @return void
*/
public function setPdf(\TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf) {
$this->pdf = $pdf;
}
You can see the debug gives pdf=> NULL from below:
My pdf column is not empty :
Did I miss something ??
UPDATE : After the answer of Pavin, I can see something in PDF, but I can't get the name of the file in href tag , maybe I need to change something after the new answer. I can see things changed in the Database, the pdf field now is boolean. that's why maybe I get pdf0.originalResource NULL, but in the backend I can upload files and see then after save and refresh !!!:
<p><f:translate key="tx_locations_domain_model_location.downloadpdf" /> <a class="download" target="_blank" title="Initiates file download" href="{location.pdf.originalResource.publicUrl}"><f:translate key="tx_locations_domain_model_location.here" />..</a></p>
UPDATE 2
my new Model/Location.php
/**
* pdf
*
* @var string
*/
protected $pdf = NULL;
...
/**
* Returns the pdf
*
* @return string $pdf
*/
public function getPdf() {
return $this->pdf;
}
/**
* Sets the pdf
*
* @param string $pdf
* @return void
*/
public function setPdf($pdf) {
$this->pdf = $pdf;
}
My TCA/Location.php
'pdf' => array(
'exclude' => 1,
'label' => 'LLL:EXT:locations/Resources/Private/Language/locallang_db.xlf:tx_locations_domain_model_location.pdf',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/pics',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 1
)
),