You are here

function easy_social_field_extra_fields in Easy Social 7.2

Same name and namespace in other branches
  1. 8.4 easy_social.module \easy_social_field_extra_fields()
  2. 8.3 easy_social.module \easy_social_field_extra_fields()
  3. 7 easy_social.module \easy_social_field_extra_fields()

Implements hook_field_extra_fields().

Makes Easy Social available in Manage Display page for content types and comments.

File

./easy_social.module, line 419
Easy social module.

Code

function easy_social_field_extra_fields() {
  $extra = array();
  $node_types = node_type_get_types();

  // Fields for node types.
  foreach ($node_types as $type => $typeobj) {
    if (variable_get_value("easy_social_{$type}_enable")) {

      // Fields for nodes.
      for ($i = 1, $num = variable_get_value("easy_social_{$type}_count"); $i <= $num; ++$i) {
        if (isset($extra['node'][$type]['display'])) {
          $extra['node'][$type]['display']["easy_social_{$i}"] = array(
            'label' => t('Easy Social !num', array(
              '!num' => $i,
            )),
            'weight' => 100 + $i,
          );
        }
        else {
          $extra['node'][$type] = array(
            'display' => array(
              "easy_social_{$i}" => array(
                'label' => t('Easy Social !num', array(
                  '!num' => $i,
                )),
                'weight' => 100 + $i,
              ),
            ),
          );
        }
      }

      // Field display for comments.
      if (module_exists('comment') && variable_get_value("easy_social_{$type}_enable")) {
        if (variable_get_value("easy_social_comment_{$type}_enable")) {
          $extra['comment']['comment_node_' . $type] = array(
            'display' => array(
              'easy_social' => array(
                'label' => t('Easy Social'),
                'weight' => 100,
              ),
            ),
          );
        }
      }
    }
  }
  return $extra;
}