[TYPO3-dev] Typo3 7.2 add file reference to extension model

Frans Saris franssaris at gmail.com
Tue Jul 21 12:54:03 CEST 2015


Hi Johannes,

when using a own model you have to tell the extbase persistence layer what
table to use if you want to use a already existing table.

see for instance
https://github.com/helhum/upload_example/blob/master/ext_typoscript_setup.txt

gr. Frans

Op ma 20 jul. 2015 om 16:19 schreef Johannes Mueller <j.f.mueller at gmx.de>:

> Hey,
>
> I try to solve the common use case of adding a file as filereference
> programmatically to an extension model. I wrote an in-depth stackoverflow
> article about that topic.
>
> http://stackoverflow.com/questions/31518799/typo3-7-2-add-file-reference-to-extension-model
>
> I'm able to fulfill my requirements via
> a) Hacking core
> b) Use the following code from
> http://wiki.typo3.org/File_Abstraction_Layer
>
> $data = array();$data['sys_file_reference']['NEW1234'] = array(
>         'uid_local' => $file->getUid(),
>         'uid_foreign' => $tt_content_uid, // uid of your content record
>         'tablenames' => 'tt_content',
>         'fieldname' => 'image',
>         'pid' => $pages_uid, // parent id of the parent page
>         'table_local' => 'sys_file',);$data['tt_content'][$tt_content_uid]
> =
> array('image' => 'NEW1234'); // set to the number of images?
>  /** @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce */$tce =
>
> \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\DataHandling\DataHandler');
> // create TCE instance$tce->start($data, array(), $new_BE_USER);
> $tce->process_datamap();
>
> I think neither of these methods are the correct way to achieve this.
>
> Thanks for infos of all kind.
>
> --
> Johannes Müller
> Informatiker (B. Sc.)
> mail: j.f.mueller at gmx.de
> tel: +49 177 557 45 45
> fax: +49 89 552 686 43
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev



More information about the TYPO3-dev mailing list