Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 5

content_fields

Definition

content_fields($field_name = NULL, $content_type_name = NULL)
contributions/cck/content.module, line 712

Description

Return a list of all fields.

Parameters

$field_name If set, return information on just this field.

$content_type_name If set, return information of the field within the context of this content type.

Code

<?php
function content_fields($field_name = NULL, $content_type_name = NULL) {
  $info = _content_type_info();

  // If there is no field name specified, return the entire fields array.
  if (!isset($field_name)) {
    return $info['fields'];
  }
  elseif (!isset($info['fields'][$field_name])) {
    return NULL;
  }
  elseif (!isset($content_type_name)) {
    return $info['fields'][$field_name];
  }
  elseif (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
    return $info['content types'][$content_type_name]['fields'][$field_name];
  }

  // If all else fails, return NULL.
  return NULL;
}
?>