content_fields

5 content.module content_fields($field_name = NULL, $content_type_name = NULL)
6 content.module content_fields($field_name = NULL, $content_type_name = NULL)

Return a list of all fields.

Parameters

$field_name: If not empty, return information on just this field.

$content_type_name: If not empty, return information of the field within the context of this content type.

Be sure to check empty() instead of isset() on field_name and content_type_name to avoid bad results when the value is set but empty, as sometimes happens in the formatter.

350 functions call content_fields()

File

contributions/cck/content.module, line 1406
Allows administrators to associate custom fields to content types.

Code

<?php
function content_fields($field_name = NULL, $content_type_name = NULL) {
  $info = _content_type_info();
  if (isset($info['fields'])) {
    if (empty($field_name)) {
      return $info['fields'];
    }
    if (isset($info['fields'][$field_name])) {
      if (empty($content_type_name)) {
        return $info['fields'][$field_name];
      }
      if (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
        return $info['content types'][$content_type_name]['fields'][$field_name];
      }
    }
  }
}
?>