1

I have two content types (job_post and job_application) linked using the node reference + node reference url nodes. When I click a link in a job_post node, a new job_application node is created, so that candidates can fill out their job application. My goal is to automatically copy the content of an cck email field from the referenced job_post node to a cck email field in the job_application node.

To achieve this, I am trying to use a cck computed field, as suggested in: http://drupal.org/node/298951.

In my computed field I have placed the following code:

$node_field[0]['value'] = db_result(db_query("SELECT field_emailfieldjobpost_value FROM content_type_job_post WHERE nid=%d",$node->field_referencefieldjobapplication[0][nid]));

where the field_referencefieldjobapplication, is the node reference field in my job_application node.

In the display format box of the computed field I have:

$display = $node_field_item['value'];

I have selected the option to store it in the database as a varchar.

However, nothing seems to happen. I never see the cck field or its content both when I create or after I save a new job application (I have even tried to see it in views and failed). Any suggestion on what might be wrong?

Thanks

user512826
  • 57
  • 5

1 Answers1

1

What I would do, is give a parameter with the link (the id of the job_post). and catch the parameter and place it in a disabled cck field.

Then write a module using the hook_node_api when a jobapplication is saved, you get the data from the job_post (using node_load) and use the data from the job-post however you want.

Jozzeh
  • 841
  • 10
  • 28
  • Thank you Jozzeh for your great advice...this really set me on the right path. For anybody interested you can find the full solution at http://stackoverflow.com/questions/4343309/how-to-query-cck-field-in-drupal – user512826 Dec 03 '10 at 19:48