You are here

function rb_cck_field_storage_key in Rules Bonus Pack 6

Helper function to get a storage key for a field.

Only fields with exactly one storage key are supported by this function, since we want to be able to store a single value when calling the function.

Parameters

string $field_name: The machine name of the field.

Return value

string The key with which the field value is stored, for example 'nid' for node references or 'value' for text fields.

8 calls to rb_cck_field_storage_key()
rb_cck_action_force_to_allowed_values in ./rb_cck.module
Action for 'rb_cck_action_force_to_allowed_values'.
rb_cck_action_get_field_value in ./rb_cck.module
Action for 'rb_cck_action_get_field_value'.
rb_cck_action_insert_value_multiple in ./rb_cck.module
Action for 'rb_cck_action_insert_value_multiple'.
rb_cck_action_merge_multiple_values in ./rb_cck.module
Action for 'rb_cck_action_merge_multiple_values'.
rb_cck_action_remove_value_multiple in ./rb_cck.module
Action for 'rb_cck_action_remove_value_multiple'.

... See full list

File

./rb_cck.module, line 201
Functions for extending CCK field management with Rules.

Code

function rb_cck_field_storage_key($field_name) {

  // Get basic field information.
  $field_information = content_fields($field_name);

  // If the field has not exactly one storage key, bail out by returning FALSE.
  if (count($field_information['columns']) != 1) {
    return FALSE;
  }

  // This is a quick cheat to get and return the storage key for the column.
  // If you're good at PHP you probably know a better way of doing this – feel
  // free to contribute a patch! (But it must be shorter than three lines.)
  foreach ($field_information['columns'] as $storage_key => $value) {
    return $storage_key;
  }
}