I am trying to combine 3 fields into one section for use during the node creation process.

In other words, when someone creates an "article" node, I'd like them to be able to submit an MP3, a PDF, and a little Test, all right next to each other like so (see attached or click here).

So I am using the code given here

And in the computed code field, I put:

// set temp variable
$count = 0;

// put array into computed field array pt1
foreach (element_children($node->field_audio) as $key) {
    $node_field[$count]['value'] = $node->field_audio[$key]['value'];
    $count++;
}

// put array into computed field array pt2
foreach (element_children($node->field_pdf) as $key) {
    $node_field[$count]['value'] = $node->field_pdf[$key]['value'];
    $count++;
}

foreach (element_children($node->field_desc) as $key) {
    $node_field[$count]['value'] = $node->field_desc[$key]['value'];
    $count++;
}

Where the:

  • field_pdf takes in a pdf file upload
  • the field_audio takes in an MP3 audio upload (and on the node view, it uses SWTTools module to make it playable on the site)
  • and lastly field_desc is just textfield.

I display this field with just:

$display = $node_field_item['value'];

I have it set to "unlimited" Number of values, so indefinite numbers can be added.

Under the "Display Fields" tab, this is what I have going:
Image Link

Is what I am looking to do possible? If so, how come this computed field isn't working? (Its actually not doing anything at all!)

Comments

mikeytown2’s picture

do a print_r() for each field to find out what type of data is in there, and if they can be combined. Also if your follow my example, the first code block didn't work, and it seems like your using the first one; it was the more elegant solution, but I couldn't get it to fly. Also what function(s) is used to display your data, computed field is setup for text only right now, so you will have to code quite a bit to make this work.

esend7881’s picture

I think I figured out what is going on. Looking at Contemplate, it looks like SWTTools doesn't hook into the node's output in time. Thus the SWTTools stuff doesn't render.

I guess the computed fields won't act as a solution when it comes to displaying the Node.

However, in the Node Editing process, is it possible to combine multiple fields into the same fieldset?

mikeytown2’s picture

combine it in the theme layer

mikeytown2’s picture

you might want to give this a shot
http://drupal.org/project/flexifield

esend7881’s picture

Status: Active » Closed (works as designed)

Thanks a lot!

I think I was under the wrong idea of what Computed Fields did. I thought it combined fields in the editing phase as well.

Seems like Flexifield doesn't yet work with FileFields. Maybe I'll try going into that module and getting it to work.

Appreciate you helping out, hopefully one day I can do the same for you!

spq101’s picture

Try removing:

from the first line of code; and

from the last line.
Worked for me.