views:

36

answers:

1

Hi ! I need to automatically assing a taxonomy term to a node based on its zipcode (field). What would be the best solution to accomplish it ?

Thanks !

+1  A: 

Implement hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) for $op == 'presave' in a custom module.

YOURMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'presave' && $node->field_zipcode);
  {
    $term = zipcode_get_term($node->field_zipcode);
    $node->taxonomy[$term->tid] = $term;
  }
}
mongolito404
Thank you, mongolito404 !
João Guilherme

related questions