Can anyone help me adapt this php snippet (if possible) as the content of a computed field?

This works as-is in node a body field, text fields, and blocks, but for various reasons I'd like to try to get it into a computed field. Thanks in advance.

 // PHP snippet to print Instrumenation taxonomy terms in tree order. (version May 11, 2008)
$vid = 3; // Taxonomy ID for Instrumentation
$treeterms = taxonomy_get_tree($vid, 0, 0); // Gets list of ALL Instrument terms in tree order
$node = node_load(arg(1)); // Gets the number of the current node.
$nodeterms = taxonomy_node_get_terms_by_vocabulary($node->nid, $vid); // Gets Instruments assigned to the current node only.
$node_term_cmp = create_function('$term_1,$term_2', 'return $term_1->tid - $term_2->tid;'); // Callback function for uinstersect.
$iterms = array_uintersect($treeterms, $nodeterms, $node_term_cmp); // Matches terms between the two lists, keeping the tree order.
$links = array();
foreach($iterms as $iterm) {
   $links[] = l($iterm->name, taxonomy_term_path($iterm));
  }
  return '<strong>Instrumentation:</strong> '. implode(', ', $links) .'<br>';

Comments

colan’s picture

Component: Miscellaneous » Code
Status: Active » Closed (won't fix)

Version 5 is no longer supported.