Closed (fixed)
Project:
FileField
Version:
6.x-3.0-beta3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Mar 2009 at 09:28 UTC
Updated:
26 Apr 2009 at 02:10 UTC
Hi,
I'm looking for some pointers. I want to do 2 things:
- If a file gets uploaded, I want to perform some additional actions. Is there a hook generated by filefield, which I can use?
- I want to change the way uploaded files are shown on the belonging node. Currently, a link and icon is generated, but I want to do something completely different. Is there a theme hook which I can use?
Thanks for your support,
Sebastian
Comments
Comment #1
advseb commentedAbout the second question, I think I can use "theme_filefield_file()", correct?
Comment #2
quicksketchPlease only ask one question per issue. Since "How to theme file display?" is the subject I'll answer that question.
Yep, copy to your template.php, rename to [name_of_your_theme]_filefield_file(), and change as necessary.
Comment #3
advseb commentedI have seen in the code that there are different field formatters. Is it possible to add an own field formatter? Also, it seems that I can't write a template file for a specific filefield, but only for filefields in general. Is that correct?
Comment #4
quicksketchThere's only one theme function available per formatter (like the theme_filefield_formatter_default() function), but you can check which field the file came from by checking $element['#field_name'].
Note the "theme_filefield_formatter_default()" theme function is only used for the "Generic files" display formatter.
Yes, make your own module and implement hook_field_formatter_info(). In truth many other modules already extend FileField's formatters to provide image display, audio or video players, thumbnails, etc. You can look at the filefield_field_formatter_info(), imagefield_field_formatter_info(), or imagecache_field_formatter_info() for some examples of this.
Comment #5
quicksketchComment #6
quicksketchadvseb wrote up a handbook page at http://drupal.org/node/420570