hook_content_def_references

Definition

hook_content_def_references(&$field_def, $field_info)
importexportapi/docs/developer/hooks/importexportapi_content.php, line 30

Description

Alter the data definition of a CCK field, as defined by content_def().

Modules that define CCK reference fields should use this hook instead of hook_def_alter(), because it allows you to easily perform standard checks and alterations on all CCK fields that exist on a site, and also because it provides useful information about a CCK field, such as its CCK field type.

Parameters

&$field_def The data definition of a CCK field, as defined through content_def(). This parameter should be modified directly, as all changes to it are passed back by reference.

$field_info An array containing information about the CCK field, such as its CCK field type.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_content_def_references(&$field_def, $field_info) {
  static $reference_delta = 1;

  if ($field_info['type'] == 'nodereference') {
    $field_def['#reference_entity'] = 'node';
    $field_def['#reference_field'] = array('nid');
    $field_def['#reference_delta'] = $reference_delta;

    $reference_delta++;
  }
}
?>