Contributions API

Calling all Drupal developers!

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

Modules in 6

content_copy_fields

Definition

content_copy_fields($type_name)
contributions/cck/modules/content_copy/content_copy.module, line 440

Description

Get all the fields for a content type.

Code

<?php
function content_copy_fields($type_name) {
  $fields = array();
  if (!$type_name) {
    return $fields;
  }
  $content_info = _content_type_info();
  foreach ($content_info['content types'][$type_name]['fields'] as $field_name => $field) {
    // Omit fields from the export if their module is not currently installed
    // otherwise the system will generate errors when the macro tries to execute their forms.
    $field_types = _content_field_types();
    $field_module = $field_types[$field['type']]['module'];
    $widget_types = _content_widget_types();
    $widget_module = $widget_types[$field['widget']['type']]['module'];

    if (!$field['locked'] && !empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
      $fields[$field_name] = $field['widget']['label'] .' ('. $field['field_name'] .')';
    }
  }
  return $fields;
}
?>