You are here

function nd_ds_fields in Node displays 7

Same name and namespace in other branches
  1. 6.3 nd.module \nd_ds_fields()
  2. 6.2 nd.module \nd_ds_fields()

Implements hook_ds_fields().

File

./nd.module, line 309
Node displays.

Code

function nd_ds_fields($type_name, $build_mode, $extra) {
  $fields = array(
    'title' => array(
      'title' => t('Title'),
      'type' => DS_FIELD_TYPE_THEME,
      'status' => DS_FIELD_STATUS_STATIC,
      'properties' => array(
        'formatters' => array(
          'nd_title_h1_nolink' => t('H1 title'),
          'nd_title_h1_link' => t('H1 title, linked to node'),
          'nd_title_h2_nolink' => t('H2 title'),
          'nd_title_h2_link' => t('H2 title, linked to node'),
          'nd_title_h2_block_nolink' => t('H2 block title'),
          'nd_title_h2_block_link' => t('H2 block title, linked to node'),
          'nd_title_p_nolink' => t('Paragraph title'),
          'nd_title_p_link' => t('Paragraph title, linked to node'),
        ),
      ),
    ),
    'author' => array(
      'title' => t('Author'),
      'type' => DS_FIELD_TYPE_THEME,
      'status' => DS_FIELD_STATUS_STATIC,
      'properties' => array(
        'formatters' => array(
          'ds_author_nolink' => t('Author'),
          'ds_author_link' => t('Author linked to profile'),
        ),
      ),
    ),
    'links' => array(
      'title' => t('Links'),
      'type' => DS_FIELD_TYPE_PREPROCESS,
      'status' => DS_FIELD_STATUS_STATIC,
    ),
    'read_more' => array(
      'title' => t('Read more'),
      'type' => DS_FIELD_TYPE_CODE,
      'status' => DS_FIELD_STATUS_DEFAULT,
      'properties' => array(
        'formatters' => array(
          'ds_eval_code' => t('Default'),
        ),
        'code' => '<?php echo l(t("Read more"), "node/$object->nid"); ?>',
      ),
    ),
    'post_date' => array(
      'title' => t('Post date'),
      'type' => DS_FIELD_TYPE_CODE,
      'status' => DS_FIELD_STATUS_DEFAULT,
      'properties' => array(
        'formatters' => array(
          'ds_eval_code' => t('Default'),
        ),
        'code' => '<?php echo format_date($object->created, "custom", "d/m/Y"); ?>',
      ),
    ),
  );

  // Check for body.
  if (isset($extra['has_body']) && $extra['has_body'] == TRUE) {
    $fields['body'] = array(
      'title' => t('Core body'),
      'type' => DS_FIELD_TYPE_THEME,
      'status' => DS_FIELD_STATUS_STATIC,
      'properties' => array(
        'formatters' => array(
          'nd_bodyfield' => t('Default'),
        ),
      ),
    );
  }

  // Taxonomy support.
  if (module_exists('taxonomy')) {

    // All terms.
    $fields['terms'] = array(
      'title' => t('Taxonomy: all terms'),
      'type' => DS_FIELD_TYPE_PREPROCESS,
      'status' => DS_FIELD_STATUS_STATIC,
    );

    // All vocabularies per content type.
    $vocabularies = taxonomy_get_vocabularies($type_name);
    if (count($vocabularies) > 0) {
      foreach ($vocabularies as $key => $vocabulary) {
        $fields['terms_' . $vocabulary->vid] = array(
          'title' => t('Taxonomy: @vocab', array(
            '@vocab' => $vocabulary->name,
          )),
          'type' => DS_FIELD_TYPE_THEME,
          'status' => DS_FIELD_STATUS_STATIC,
          'properties' => array(
            'css-class' => 'field-terms field-terms-' . $vocabulary->vid,
            'formatters' => array(
              'nd_terms_per_vocabulary_space' => t('Separated by space'),
              'nd_terms_per_vocabulary_linked_space' => t('Separated by space, linked to term'),
              'nd_terms_per_vocabulary_comma' => t('Separated by comma'),
              'nd_terms_per_vocabulary_linked_comma' => t('Separated by comma, linked to term'),
            ),
          ),
        );
      }
    }
  }

  // Upload support.
  if (module_exists('upload') && $build_mode != 'teaser' && variable_get("upload_{$type_name}", 1)) {
    $fields['files'] = array(
      'title' => t('Core upload'),
      'type' => DS_FIELD_TYPE_IGNORE,
      'status' => DS_FIELD_STATUS_STATIC,
    );
  }

  // Book support.
  if (module_exists('book') && $type_name == 'book') {
    $fields['book_navigation'] = array(
      'title' => t('Book navigation'),
      'type' => DS_FIELD_TYPE_FUNCTION,
      'status' => DS_FIELD_STATUS_STATIC,
      'properties' => array(
        'formatters' => array(
          'nd_book_navigation' => t('Book navigation'),
        ),
      ),
    );
  }

  // Comment support (count and add new comment link)
  return array(
    'nd' => $fields,
  );
}