You are here

function nodehierarchy_views_data in Node Hierarchy 6.2

Same name and namespace in other branches
  1. 6.3 includes/views/nodehierarchy.views.inc \nodehierarchy_views_data()
  2. 7.4 includes/views/nodehierarchy.views.inc \nodehierarchy_views_data()
  3. 7.2 includes/views/nodehierarchy.views.inc \nodehierarchy_views_data()

Implementation of hook_views_data()

File

includes/views/nodehierarchy.views.inc, line 26
Implementations of Views 2 Hooks for nodehierarchy_views module

Code

function nodehierarchy_views_data() {

  // Basic table information.
  $data['nodehierarchy_menu_links']['table']['group'] = t('Node Hierarchy');
  $data['nodehierarchy_menu_links']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );

  // An aliased table to connect {menu_links} to {nodes}
  $data['nh_menu_links']['table']['group'] = t('Node Hierarchy');
  $data['nh_menu_links']['table']['join'] = array(
    'node' => array(
      'table' => 'menu_links',
      'left_table' => 'nodehierarchy_menu_links',
      'left_field' => 'mlid',
      'field' => 'mlid',
    ),
  );
  $data['nh_menu_links']['weight'] = array(
    'title' => t('Child Weight'),
    'help' => t('The sort order of the child node.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Link back to the node table via plid to get the parent node.
  $data['nh_parent']['table']['group'] = t('Node Hierarchy');
  $data['nh_parent']['table']['join'] = array(
    'node' => array(
      'table' => 'nodehierarchy_menu_links',
      'left_table' => 'nh_menu_links',
      'left_field' => 'plid',
      'field' => 'mlid',
    ),
  );

  // Parent nid.
  $data['nh_parent']['nid'] = array(
    'title' => t('Parent nid'),
    'help' => t('Immediate descendants of the node.'),
    // Information for accepting a parent as an argument.
    'argument' => array(
      'field' => 'nid',
      'handler' => 'views_handler_argument_node_nid',
      'click sortable' => TRUE,
    ),
    'relationship' => array(
      'base' => 'node',
      'field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('Parent nid'),
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
      'allow empty' => TRUE,
    ),
  );

  // Link back to the node table via plid to get the parent node.
  $data['nh_ancestor']['table']['group'] = t('Node Hierarchy');
  $data['nh_ancestor']['table']['join'] = array(
    'node' => array(
      'handler' => 'views_join_nodehierarchy_ancestor',
      'arguments' => array(
        'table' => 'nodehierarchy_menu_links',
        'left_table' => 'nh_menu_links',
        'left_field' => 'plid',
        'field' => 'mlid',
      ),
    ),
  );
  $data['nh_ancestor']['nid'] = array(
    'title' => t('Ancestor nid'),
    'help' => t('All descendants of the node.'),
    // Information for accepting a parent as an argument.
    'argument' => array(
      'field' => 'nid',
      'handler' => 'views_handler_argument_node_nid',
      'click sortable' => TRUE,
    ),
    'relationship' => array(
      'base' => 'node',
      'field' => 'nid',
      'handler' => 'views_handler_relationship',
      'label' => t('Ancestor nid'),
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
      'allow empty' => TRUE,
    ),
  );
  return $data;
}