Feature #16323


Implement file_reference for TCA "group" type. Files can be referenced instead of copied to upload folder

Added by Martin Borer almost 17 years ago. Updated almost 14 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Sprint Focus:


If you let "uploadfolder" empty in your TCA Settings. Like:
"movie" => Array (
"exclude" => 1,
"label" => "LLL:EXT:ext_collect/",
"config" => Array (
"type" => "group",
"internal_type" => "file",
"allowed" => "flv",
"max_size" => 500000,
"uploadfolder" => "",
"size" => 1,
"minitems" => 1,
"maxitems" => 1,

The selected File will not be copied. It stores only the absolute Path of the file (great!).
But after saving the record, the selector box shows the whole "long" path. The Filename isn't identifiable anymore. It would be great if the Filename apears insted of the "Upload" Fild, witch isn't used anymore.

This Feature is used by MailformPlus and some of my privat extensions... ;)

(issue imported from #M6039)


6039.patch (1.78 KB) 6039.patch Administrator Admin, 2008-02-27 01:48
6039_v2.patch (2.72 KB) 6039_v2.patch Administrator Admin, 2008-02-27 22:46
6039_v3.patch (2.77 KB) 6039_v3.patch Administrator Admin, 2008-02-28 00:32
6039_v4_new_internal_type.patch (10.1 KB) 6039_v4_new_internal_type.patch Administrator Admin, 2008-03-12 21:51
6039_v5_with_impexp.patch (17 KB) 6039_v5_with_impexp.patch Administrator Admin, 2008-08-02 13:47
6039_v5.diff (12.1 KB) 6039_v5.diff Administrator Admin, 2008-08-19 12:06
6039_v6.diff (18.3 KB) 6039_v6.diff Administrator Admin, 2008-08-19 21:48
typo3_fileIntegrityCheckWithSupportOfDirectReferences.patch (2.06 KB) typo3_fileIntegrityCheckWithSupportOfDirectReferences.patch Administrator Admin, 2008-10-29 15:47
6039_v7.patch (19.8 KB) 6039_v7.patch Administrator Admin, 2009-01-21 14:46
6039_v8.diff (19.7 KB) 6039_v8.diff Administrator Admin, 2009-03-27 23:01
6039_v9.diff (21.5 KB) 6039_v9.diff Administrator Admin, 2009-05-25 21:50
T3X_6039-0_0_0-z-200906261532.t3x (10.4 KB) T3X_6039-0_0_0-z-200906261532.t3x Administrator Admin, 2009-07-31 14:10
6039_v14.diff (20.6 KB) 6039_v14.diff Administrator Admin, 2009-07-31 14:10
6039_v14_doku.txt (371 Bytes) 6039_v14_doku.txt Administrator Admin, 2009-07-31 14:10
6039_v15.diff (20.4 KB) 6039_v15.diff Administrator Admin, 2009-08-01 20:17
Actions #1

Updated by Typoheads GmbH over 16 years ago


Actions #2

Updated by Yannick Pavard over 16 years ago

+1 ;)

But I prefer to do not store absolute path, but only fileadmin/mytemplate/news.html

Thank You

Actions #3

Updated by Peter Wechtersbach about 16 years ago


Also prefer only fileadmin/mytemplate/...

Thank you :)

Actions #4

Updated by Oliver Hader about 16 years ago

Could some please add a patch then? Thanks! ;-)

Actions #5

Updated by Martin Borer about 16 years ago

Uploaded a Patch: 6039.patch

If "uploadfolder" is emty, the Upload Field will be dropped and the stored path is relative to site root.

I'm not sure if the line:
$valueArray[$key] = substr($theFile, strpos($theFile, "fileadmin/"));
is a god solution... Is there a T3-Function for this issue?

Actions #6

Updated by Martin Borer about 16 years ago

PS: Adding references to selected files is missing in my patch!

Actions #7

Updated by Martin Borer about 16 years ago

Uploaded new patch: 6039_v2.patch

- with file references support.
- replaced line
$valueArray[$key] = substr($theFile, strpos($theFile, "fileadmin/"));
with a better solution

Actions #8

Updated by Benni Mack about 16 years ago

Is this is a bug or a feature?

If it's a bug, please submit it to the core list so it can go to in the 4.2 release!

Actions #9

Updated by Benni Mack about 16 years ago

I also read through your patch (v2). Quite cool.

A couple of things to fix:

- Please create the patch located to the base directory of the SVN branch.
- Hunk #2: Please use curly braces around if statements
- Hunk #3: Curly braces here too would be nice. Also use single quotes : && $config['uploadfolder']!='')
- Hunk #5: could be written as
if (count($valueArray)) {
foreach ($valueArray as &$theFile) {
if (t3lib_div::isFirstPartOfStr($theFile,PATH_site)) {
$theFile = substr($theFile,strlen(PATH_site));

Actions #10

Updated by Martin Borer about 16 years ago

Uploaded clean patch: 6039_v3.patch

@Benjamin Fischer
Thanks for your hints. Liked the "foreach" one! ;)

I will report this "bug" to the list. It's e mix between a bug and a feature.
thumbnails and file references were not working with an emty "uploadfolder" option.

Actions #12

Updated by Martin Borer about 16 years ago

Uploaded new patch: 6039_v4_new_internal_type.patch

There are now 2 ways to have direct file references.

1st and better way
There is now a new internal_type for TCA->group called 'file_reference' it's almost a alias for 'file' with the difference that the option 'uploadfolder' is always ignored, so it's always a file reference.

2nd way (not so good)
internal_type 'file' with empty 'uploadfolder' Option. With this config the behavior is exactly the same like the internal_type 'file_reference'.

Actions #13

Updated by Martin Borer about 16 years ago

There is something missing in my patch!
Import data from a *.t3d file with TCA->group->internal_type 'file_reference' records or 'file' with empty 'uploadfolder' records is not working.

Import message (example):
fileadmin/user_upload/castTest/rechner.jpg, fileadmin/user_upload/castTest/verwaltung.jpg
typo3temp/\imp9C.tmp, typo3temp/\imp9D.tmp

which core files are responsible for import / export *.t3d ?

Actions #14

Updated by Michiel Roos about 16 years ago

.-(michiel@Food:1,28 0,94 0,77)---[...s/alien42/typo3]
`-$ grep ril t3d *
(michiel@Food:1,28 0,94 0,77)---[...s/alien42/typo3]

Actions #15

Updated by Benni Mack almost 16 years ago

what's the status here?

Actions #16

Updated by Martin Borer almost 16 years ago

New patch: 6039_v5_with_impexp.patch

New with import / export support of group->file_reference fields.
Could someone of the core 'gurus' review this patch? ;)

There are still some minor flaws. The relative path for example, the path to the file is only identifiable if thumbnails are active for the file_reference field.

Actions #17

Updated by Dmitry Dulepov almost 16 years ago

I took the version from the core list and updated it a bit. Only then I saw that you already made another here :( Please, inform core list next time if you do...

I attached my version 96039_v5.diff).

Actions #18

Updated by Martin Borer almost 16 years ago

New patch: 6039_v6.diff
(Typo3 4.2-Branch Revision 4005)

Merged 6039_v5.diff from Dimitry with 6039_v5_with_impexp.patch.

I've made also a BUGFIX! In 6039_v5_with_impexp.patch, some lines were outside a foreach loop. (only last selected file was converted to a relative path.)

Please don't use 6039_v5_with_impexp.patch!

Actions #19

Updated by Michael Miousse over 15 years ago

will it be integrated in futur version of typo3?
because i made an extension from the patch and i want to know if it would be useful to put it on the ter

Actions #20

Updated by Stefan Galinski over 15 years ago

I have tested the latest patch and it works like expected. IMHO it's really an important patch to get rid of the endless copying stuff in TYPO3.

Actions #21

Updated by Stefan Galinski over 15 years ago

I have uploaded the file "typo3_fileIntegrityCheckWithSupportOfDirectReferences.patch" which is a followup of the last patch. It contains a workaround for the database<->file references functions. This one has always reported any direct references to fileadmin files in the "missing files" section. You can find the corresponding backend function here: DB Check->Database Relations.

BTW: It's just a workaround, because the whole code of the file must be refactored.

Actions #22

Updated by Stefan Galinski over 15 years ago

Any news?

BTW: The following two typoscript lines are important to render images of tt_content elements in the frontend (if css_styed_content is used).

tt_content.image.20.imgPath =
tt_content.textpic.20.imgPath < tt_content.image.20.imgPath

Actions #23

Updated by Stefan Galinski over 15 years ago

Latest patch is against 4.2.4 and includes my file integrity patch.

Actions #24

Updated by Martin Borer over 15 years ago


Thanks for your merged patch. I've reported your new patch to the typo3 core list:

Actions #25

Updated by Daniel Schmitzer about 15 years ago

The Patch works fine and fix the problems in 4.2.1

Actions #26

Updated by Steffen Kamper about 15 years ago

I attached a patch that fits to latest trunk.

Actions #27

Updated by Martin Borer almost 15 years ago

New patch: 6039_v9.diff
(Typo3 4.2-Branch Revision 5493)

- Bugfix 1: internal_type 'folder' shows now the path and not only the folder name.

- Bugfix 2: image title attribute of thumbnails (internal_type -> file_reference) now displays the filesize instead of 'FILE NOT FOUND!'

Actions #28

Updated by Christian Kuhn almost 15 years ago

Committed attached v15 to trunk, rev. 5744.


Also available in: Atom PDF