You are here

function nd_get_fields in Node displays 6

API function to get all fields.

5 calls to nd_get_fields()
nd_add_fields in includes/nd.display.inc
Add fields to display overview form.
nd_display_submit in includes/nd.display.inc
Save fields per context.
nd_fields in includes/nd.fields.inc
Fields overview.
_nd_nodeapi in ./nd.module
Helper function to alter node properties
_nd_preprocess_node in ./nd.module
Helper function used in either nd_preprocess_node or other preprocess function.

File

./nd.module, line 429
Main node displays file.

Code

function nd_get_fields($node_type, $has_body, $build_mode) {
  static $static_fields = array();
  if (!isset($static_fields[$node_type][$build_mode])) {

    // Fields in code.
    $fields = module_invoke_all('nd_fields', $node_type, $has_body, $build_mode);

    // Fields via the UI.
    $db_fields = variable_get('nd_fields', array());
    if (!empty($db_fields)) {
      foreach ($db_fields as $key => $field) {
        $fields[$key] = array(
          'title' => check_plain($field['title']),
          'code' => isset($field['block']) ? $field['block'] : $field['code'],
          'type' => $field['type'],
          'render' => isset($field['render']) ? $field['render'] : '',
        );
        $exclude = isset($field['exclude'][$node_type]) && $field['exclude'][$node_type] === $node_type ? TRUE : FALSE;
        if ($exclude) {
          unset($fields[$key]);
        }
      }
    }

    // Give modules a change to alter fields.
    drupal_alter('nd_fields', $fields);
    $static_fields[$node_type][$build_mode] = $fields;
  }
  return $static_fields[$node_type][$build_mode];
}