You are here

function profile_views_add_field in Views (for Drupal 7) 5

Add profile fields to view table

1 call to profile_views_add_field()
profile_views_tables in modules/views_profile.inc
This include file implements views functionality on behalf of profile.module

File

modules/views_profile.inc, line 63

Code

function profile_views_add_field(&$table, $field) {
  $name = 'value';
  $label = t('Profile: @field-name', array(
    '@field-name' => $field->title,
  ));
  switch ($field->type) {
    case 'vocabulary':
      $help = t('This will display all options of the profile field %field-name. ', array(
        '%field-name' => $field->title,
      ));
      $others = array(
        'sortable' => true,
        'handler' => 'views_handler_field_profile_vocabulary',
      );
      break;
    case 'selection':
      $help = t('This will display all options of the profile field %field-name. ', array(
        '%field-name' => $field->title,
      ));
      $others = array(
        'sortable' => true,
        'handler' => 'views_handler_field_profile_selection',
      );
      break;
    case 'date':
      $help = t('Display the date of the %field-name field.', array(
        '%field-name' => $field->title,
      ));
      $others = array(
        'sortable' => false,
        'handler' => 'views_handler_field_profile_date',
      );
      break;
    case 'checkbox':
      $help = t('Checkbox based profile field help');
      $others = array(
        'sortable' => true,
        'handler' => 'views_handler_field_profile_checkbox',
      );
      break;
    case 'textarea':
      $help = t('Other types based profile field help');
      $others = array(
        'sortable' => true,
        'handler' => 'views_handler_field_profile_textarea',
      );
      break;
    default:
      $help = t('Other types based profile field help');
      $others = array(
        'sortable' => true,
        'handler' => 'views_handler_field_profile_default',
      );
  }
  views_table_add_field($table, $name, $label, $help, $others);
}