_nodereference_potential_references

Versions
5
_nodereference_potential_references($field, $return_full_nodes = FALSE, $string = '', $exact_string = false)
6
_nodereference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL)

Fetch an array of all candidate referenced nodes.

This info is used in various places (allowed values, autocomplete results, input validation...). Some of them only need the nids, others nid + titles, others yet nid + titles + rendered row (for display in widgets). The array we return contains all the potentially needed information, and lets consumers use the parts they actually need.

Parameters

$field The field description.

$string Optional string to filter titles on (used by autocomplete).

$match Operator to match filtered name against, can be any of: 'contains', 'equals', 'starts_with'

$ids Optional node ids to lookup (the $string and $match arguments will be ignored).

$limit If non-zero, limit the size of the result set.

Return value

An array of valid nodes in the form: array( nid => array( 'title' => The node title, 'rendered' => The text to display in widgets (can be HTML) ), ... )

▾ 4 functions call _nodereference_potential_references()

nodereference_allowed_values in contributions/cck/modules/nodereference/nodereference.module
Implementation of hook_allowed_values().
nodereference_autocomplete in contributions/cck/modules/nodereference/nodereference.module
Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
nodereference_autocomplete_validate in contributions/cck/modules/nodereference/nodereference.module
Validate an autocomplete element.
nodereference_field in contributions/cck/modules/nodereference/nodereference.module
Implementation of hook_field().

Code

contributions/cck/modules/nodereference/nodereference.module, line 803

<?php
function _nodereference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
  static $results = array();

  // Create unique id for static cache.
  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
  if (!isset($results[$cid])) {
    $references = FALSE;
    if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
      $references = _nodereference_potential_references_views($field, $string, $match, $ids, $limit);
    }
    // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.

    if ($references === FALSE) {
      $references = _nodereference_potential_references_standard($field, $string, $match, $ids, $limit);
    }

    // Store the results.
    $results[$cid] = !empty($references) ? $references : array();
  }

  return $results[$cid];
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.