It would be awesome if this module allowed inheritance by node reference.
I made myself a Computed field that does this, but it is only on a proof-of-concept basis. (My skills in module development are far to modest to implement it as a CCK setting, unfortunately.)

I'm attaching the code if it could be of any interest.

Cheers!

// This code can be inserted into a CCK Computed Field to allow the field to inherit values from specified references

// Set parameters
$field_name = "field_name_here";
$reference_name = "field_nodereference_inheritance";
$default_value = "default";


// Start searching on the current node

$tmpnode = $node;
$value = $tmpnode->{$field_name}[0]['value'];


// Parameter for failsafe
$i = 0;
$i_max = 15;

// Keep searching until a value is found or there is no reference to load
// Note that node_load is carried out as a part of loop evaluation
while ($value == '' && ($tmpnode = node_load($tmpnode->{$reference_name}[0]['nid']))) {
  $value = $tmpnode->{$field_name}[0]['value'];
  
  // Break if number of recursions is suspiciously high
  $i++;
  if($i == $i_max) {
    dsm("Reached maximum recursion limit when trying to find $field_name inheritance, falling back to defaul value ($default_value).");
    break;
  }
}

// Set default value, if reasonable
if ($value == '') {$value = $default_value;}

// Set field value
$node_field[0]['value'] = $value;

Comments

joelstein’s picture

I agree; that's a great idea. I implemented Node Reference support in the 6.x-2.0 release. Please give it a test run and let me know if it works for you.

finex’s picture

Hi, why not write about the new feature in the module description?

joelstein’s picture

Thanks, FiNeX. Forgot to do that. Also forgot to close this ticket. Eek!

joelstein’s picture

Status: Active » Fixed

Okay, the description has been updated on the module page. Also, I updated the screenshot.

finex’s picture

great! I've not yet tried this module, but I'll do soon. It looks very interesting.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.