You are here

function fieldgroup_get_parents in Content Construction Kit (CCK) 6.3

Return an array of the parents for a field or group.

Parameters

$content_type The content type of the field/group.:

$name The name of a group or field.:

File

modules/fieldgroup/fieldgroup.module, line 355
Create field groups for CCK fields.

Code

function fieldgroup_get_parents($content_type, $name) {
  $is_group = substr($name, 0, 6) == 'group_';
  $counter = 0;
  if ($is_group) {
    $parents[$counter] = $name;
  }
  else {
    if ($result = db_result(db_query("SELECT group_name FROM {" . fieldgroup_fields_tablename() . "} WHERE type_name = '%s' AND field_name = '%s'", $content_type, $name))) {
      $parents[$counter] = $result;
    }
  }
  while ($result = db_result(db_query("SELECT parent FROM {" . fieldgroup_tablename() . "} WHERE type_name = '%s' AND group_name = '%s'", $content_type, $parents[$counter]))) {
    $counter++;
    $parents[$counter] = $result;
  }
  return $parents;
}