[TYPO3-mvc] Typo3 extbase FAL file download
Ganapati Bhat
ganybhat at gmail.com
Mon Jun 24 10:32:58 CEST 2013
Using Extbase plugin, I wanted to show file download link.
I am using typo3 v6.1 FAL file structure.
But I am unable to get original file download link.
In file ext_tables.sql
CREATE TABLE tx_myext_domain_model_test (
# ...
files varchar(255) DEFAULT '' NOT NULL,
# ...
);
In file Configuration/TCA/Test.php
$TCA['tx_myext_domain_model_test'] = array(
// ...
'files' => array(
'exclude' => 1,
'label' => 'Files',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('files',
array(
'appearance' => array(
'createNewRelationLinkTitle' =>
'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
),
), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),
),
// ...
);
In file Classes/Domain/Model/Test.php
class Test extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
// ...
/**
* Files
* @var
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
*/
protected $files;
/**
* Returns the files
*
* @return
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
$files
*/
public function getFiles() {
return $this->files;
}
}
In file Classes/Controller/TestController.php
class TestController extends
\TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
// ..
public function listAction() {
$tests = $this->testRepository->findAll();
$this->view->assign('tests', $tests);
}
// ..
}
In file Resources/Private/Templates/Test/List.html
<f:for each="{tests}" as="test" iteration="itemIterator">
<f:debug title="Debug of test">{test.files}</f:debug>
<f:for each="{test.files}" as="file">
<a href="{f:uri.image(src:file.uid,treatIdAsReference:1)}">
<f:image src="{file.uid}" alt="" width='101' height="67"
treatIdAsReference="1"/>
</a>
<p>{file.originalResource.originalFile.title}</p>
</f:for>
Here If in debug "originalResource" is NULL.
Anybody know how to get original file link here ?
Thank you.
More information about the TYPO3-project-typo3v4mvc
mailing list