You are here

views_taxonomy_edge.module in Taxonomy Edge 7.2

Integration with Views using Taxonomy Edge.

Overrides the depth arguments and uses Taxonomy Edge for these. This now allows using 'all' as a depth argument.

File

views_taxonomy_edge/views_taxonomy_edge.module
View source
<?php

/**
 * @file
 *
 * Integration with Views using Taxonomy Edge.
 *
 * Overrides the depth arguments and uses Taxonomy Edge for these.
 * This now allows using 'all' as a depth argument.
 */

/**
Implements hook_views_api().
*/
function views_taxonomy_edge_views_api() {
  return array(
    'api' => 3,
  );
}

/**
 * Implements hook_views_data_alter().
 */
function views_taxonomy_edge_views_data_alter(&$data) {

  // Override term_node logic
  $data['node']['term_node_tid_depth'] = array(
    'help' => t('Display content if it has the selected taxonomy terms, or children of the selected terms. Due to additional complexity, this has fewer options than the versions without depth.'),
    'real field' => 'nid',
    'argument' => array(
      'title' => t('Has taxonomy term ID (with depth)'),
      'handler' => 'views_handler_argument_term_edge_node_tid_depth',
      'accept depth modifier' => TRUE,
    ),
    'filter' => array(
      'title' => t('Has taxonomy terms (with depth)'),
      'handler' => 'views_handler_filter_term_edge_node_tid_depth',
    ),
  );
  $data['node']['term_node_tid_depth_modifier'] = array(
    'title' => t('Has taxonomy term ID depth modifier'),
    'help' => t('Allows the "depth" for Taxonomy: Term ID (with depth) to be modified via an additional contextual filter value.'),
    'argument' => array(
      'handler' => 'views_handler_argument_term_edge_node_tid_depth_modifier',
    ),
  );

  // Tell taxonomy_term_data how to join with the edge tables
  $data['taxonomy_term_data']['table']['join']['taxonomy_term_edge_path'] = array(
    'field' => 'tid',
    'left_field' => 'tid',
    'type' => 'INNER',
  );
  $data['taxonomy_term_data']['table']['join']['taxonomy_term_edge_order'] = array(
    'left_table' => 'taxonomy_term_edge_path',
    'left_field' => 'tid',
    'field' => 'tid',
    'type' => 'INNER',
  );
  $data['taxonomy_term_data']['table']['join']['taxonomy_term_edge'] = array(
    'left_table' => 'taxonomy_term_edge_path',
    'left_field' => 'tid',
    'field' => 'tid',
    'type' => 'INNER',
  );
}