views:

24

answers:

2

Hello all,

I'm new to CCK development and I'm having some problems creating a new field for my system.

In particular, I'm writing a widget that attaches a file to a field. Once that happens, how can a formatter function figure out which field and node it's referring to in order to retrieve the right file associated with that field? Is there any way to store the file information directly in the $element array?

I'd appreciate examples that show how this could be done. I'd also appreciate good references on how to build widgets and formatters...

Thanks so much!

+1  A: 

A long time ago I wrote about CCK field formatters on my blog.

Field formatters are basically theme functions, CCK call them when it has gotten the content and want it rendered. The nature of the content can vary a lot, it depends what field/widget that is used.

googletorp
Hello googletorp,Thanks for your article. It's very helpful! However, I still need to know how to store information about a file in the $element array in order to know which file to present for a given field... how to do that?
A: 

I'm not exactly sure what your end goal is, but there may already be a module that does what you are trying to do. If you could explain it a little more I can let you know if I know of a module that would be of help to you.

Kappaluppa
Hi Kappaluppa,We're building a CCK field widget that uploads a file to the server. What I'm trying to figure out is how to build a formatter that is able to a) recognize which file is associated with each field, and b) display that file in an appropriate way.I don't know how to keep track of the relationship between files and fields. Is that something that should be stored as part of hidden form elements? If so, how to access that from inside the formatter? How do people do that?Thanks so much!