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

Johannes Mueller j.f.mueller at gmx.de
Tue Jul 21 16:51:31 CEST 2015


wow. precise :)
that worked immediately. thanks a lot!

2015-07-21 12:54 GMT+02:00 Frans Saris <franssaris at gmail.com>:

> 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
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev




-- 
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



More information about the TYPO3-dev mailing list