You are here

function nodereference_autocomplete in Content Construction Kit (CCK) 6.2

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

Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users

3 string references to 'nodereference_autocomplete'
nodereference_menu in modules/nodereference/nodereference.module
Implementation of hook_menu().
nodereference_widget in modules/nodereference/nodereference.module
Implementation of hook_widget().
nodereference_widget_settings in modules/nodereference/nodereference.module
Implementation of hook_widget_settings().

File

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

Code

function nodereference_autocomplete($field_name, $string = '') {
  $fields = content_fields();
  $field = $fields[$field_name];
  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
  $matches = array();
  $references = _nodereference_potential_references($field, $string, $match, array(), 10);
  foreach ($references as $id => $row) {

    // Add a class wrapper for a few required CSS overrides.
    $matches[$row['title'] . " [nid:{$id}]"] = '<div class="reference-autocomplete">' . $row['rendered'] . '</div>';
  }
  drupal_json($matches);
}