I posted earlier about integrating the flag module with filefield, but I don't think that is going to work for one of our use cases since what I really want is to let a user upload a bunch of files, but let them designate things about each file. Similar to "list" or "active" or "preferred". These might be checkboxes or radiobuttons if only one file should get the designation per node.

My question is:

1) anyone else implement this type of thing yet?

2) What is the best way to add extra fields into each filefield field in the node_from? IS there a hook or do i need to alter the form directly?

Comments

quicksketch’s picture

There are actually two approaches currently to what you're describing, which at it's core is really just a "grouping of fields". Where you're wanting to put a file field in a group with other fields, and then have them all available in a multiple field together. If you're only doing one-file-per-node, then you can just add a new checkbox or field to the node form as normally. But if needing to group these fields together you have two options:

- The Flexifield module, which allows you to combine several fields together with CCK by defining multiple types (warning, a little janky, but functional).
- The Multigroup module will eventually be added to CCK core directly, however it's been the longest ongoing issue I've ever seen (currently at 564 comments), so it might take a little while yet before it's finished, but it will probably be the better long term solution.

Finally, if you're not wanting a contributed module solution but want to code it yourself, you'll need a combination of hook_elements() to add an additional #process function to FileFields (similar to the way FileField Sources adds new fields to FileFields, but you'll also need this CCK patch which adds drupal_alter() to field settings so that you can add a new column to FileField table rows.

quicksketch’s picture

Hey frankcarey, I just read your other issue at #435130: Flag Files, which makes me think I might have misunderstood the question. How is this question related to the other issue?

frankcarey’s picture

When I stared out, I had 2 goals.

1) Allow users to designate one of their uploaded files in their content_profile as their "profile picture" when they're editing a node. Same basic use case for blogs, where one image will be a larger "featured" image at the beginning of the article.

2) Allow users to flag individual imagefield images. (we might use for bookmarking, or flagging as inappropriate).

I was originally going to use flag for both use cases with an overarching flag_file module, but I'm doubtful how well it will work for (1), since flag can't store the nid, along with the fid (file id), though on deeper inspection, i guess it could still be done as long as no files are shared between nodes. What do you think?

(2) relates to these, while (1) relates to the current issue.
#457094: Help with flag module integration
#457076: theme_imagecache_formatter not a registered theme function

#435130 was is starting point where I'm trying to do this for ALL files, but since each formatter handles the output (including imagefield and imagecache for images), then I have to integrate with each formatter separately, no? :(

Thanks for the help.

frankcarey’s picture

a related question:

Is the delta order consistent? i.e. can I coun't on the first in the list of files being delta [0], followed by [1] if there are two... etc? Dragging the field to a different order changes the delta?

Thanks

quicksketch’s picture

Yep that's right. Fields should always start at delta == 0. Reordering the fields simply changes the deltas.

frankcarey’s picture

and about the field formatters, if I want to output the flag link with every filefield, I have to override every formatter theme function, there is no central theme function i can use instead?

quicksketch’s picture

Status: Active » Closed (fixed)

That's right, unfortunately there's no central theme function for all FileField output, though you can override the content-field.tpl.php file, which controls all CCK output and target FileField's specifically.

I'm closing this issue since it's been 2 months since the last activity, which diverged into custom module development help, which is beyond the scope of the help offered in the FileField issue queue.