You are here

function submitted_by_field_extra_fields in Submitted By 7

Implements hook_field_extra_fields().

Adds a Submitted By field to the Manage Display page for each content type for which it is enabled.

File

./submitted_by.module, line 116
Take over the "Submitted by" theme function.

Code

function submitted_by_field_extra_fields() {
  $extra = array();
  $field = array(
    'display' => array(
      'submitted_by' => array(
        'label' => t('Submitted by'),
        'description' => t('Submitted By information.'),
        'weight' => 0,
        'visible' => FALSE,
      ),
    ),
  );

  // If the Comment module is enabled, we'll do those too.
  $comments = module_exists('comment');
  foreach (node_type_get_types() as $type) {
    $show_submitted_by = variable_get('node_submitted_' . $type->type, TRUE);
    $submitted_by = variable_get('submitted_by_' . $type->type, NULL);
    if ($show_submitted_by && $submitted_by) {
      $extra['node'][$type->type] = $field;
    }
    $submitted_by = variable_get('submitted_by_comment_node_' . $type->type, NULL);
    if ($comments && $submitted_by) {
      $extra['comment']['comment_node_' . $type->type] = $field;
    }
  }
  return $extra;
}