You are here

function custom_pub_views_data_alter in Custom Publishing Options 6

Same name and namespace in other branches
  1. 7 custom_pub.module \custom_pub_views_data_alter()

Implements hook_views_data_alter().

File

./custom_pub.module, line 397
Adds the ability to add Custom publishing options to the node Add/Edit form.

Code

function custom_pub_views_data_alter(&$data) {
  $types = variable_get('custom_pub_types', array());
  $node_types = node_get_types();
  foreach ($types as $type) {
    $used_in = array();
    foreach ($node_types as $node_type) {
      if (!empty($type['node_types'][$node_type->type])) {
        $used_in[] = $node_type->name;
      }
    }

    // published status
    $data['node'][$type['type']] = array(
      'title' => t($type['name']),
      'help' => t('Custom Publishing Option. Appears in: !types', array(
        '!types' => implode(', ', $used_in),
      )),
      'field' => array(
        'handler' => 'views_handler_field_boolean',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_boolean_operator',
        'label' => t($type['name']),
        'type' => 'yes-no',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    );
  }
}