I'm trying to get the computed field to look up the titles and nids of content_type, check to see if the title matches the title that was selected in my "first field" field ($node->field_first_field[0]['value']) and if it does, set the value of the computed field to the nid of that title's node.

I got it to work (printed out the nid) in a block and I can't figure out why it won't work in computed field. Is something about my code off? Am I missing something else?

$result = db_query(
   "SELECT title, nid
   FROM {node} n
   WHERE n.status = 1
    AND n.type = 'content_type'"
);

while ($row = db_fetch_array($result)) {
   $targetNid = $row['nid'];
   $testTitle = $row['title'];
   if ($node->field_first_field[0]['value'] == $testTitle) {
      $output = $targetNid;
   }
}

$node_field[0]['value'] = $output;

Comments

pog-wmt’s picture

Status: Active » Closed (fixed)

Bah. My normal type of mistake: a painfully simple one. I resaved the node.