You are here

function nodereference_autocomplete in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6.3 modules/nodereference/nodereference.module \nodereference_autocomplete()
  2. 6 modules/nodereference/nodereference.module \nodereference_autocomplete()
  3. 6.2 modules/nodereference/nodereference.module \nodereference_autocomplete()

Retrieve a pipe delimited string of autocomplete suggestions

1 string reference to 'nodereference_autocomplete'
nodereference_menu in ./nodereference.module
Implementation of hook_menu().

File

./nodereference.module, line 491
Defines a field type for referencing one node from another.

Code

function nodereference_autocomplete($field_name, $string = '') {
  $fields = content_fields();
  $field = $fields[$field_name];
  $matches = array();
  foreach (_nodereference_potential_references($field, TRUE, $string) as $row) {
    $matches[$row->node_title . ' [nid:' . $row->nid . ']'] = _nodereference_item($field, $row);
  }
  print drupal_to_js($matches);
  exit;
}