I have two taxonomy term vocabularies:
- Model
- Parts
A part is associated with a model via a taxonomy term reference field on the Parts term. The idea is when a user clicks on a model and is viewing the taxonomy term page, they should be able to see all the parts that reference that model.
What I want is something similar to the views contextual filter "Content:NID" and "Content ID from URL".
All of the Views contextual filters and fields appear to be very focused on nodes, so I'm guessing Views just doesn't have this feature yet.
EDIT: Here is the query I want:
SELECT entity_id from taxonomy_term_data as tt
JOIN field_data_field_part_model as pm ON tt.tid = pm.field_part_model_tid
WHERE pm.field_part_model_tid = CURRENT_TERM_TID_GOES_HERE
EDIT:
Here is the view that I am using. Instead of finding the parts that reference this model, it finds every single part that has anything entered in field_parts_model. A part can be compatible with more than one model, and so field_parts_model is multiple cardinality, maybe that is messing it up? This doesn't make any sense.
$view = new view();
$view->name = 'related_terms';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Related Terms';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'entity';
$handler->display->display_options['row_options']['view_mode'] = 'teaser';
/* Relationship: Taxonomy term: Part Model (field_part_model) */
$handler->display->display_options['relationships']['field_part_model_tid']['id'] = 'field_part_model_tid';
$handler->display->display_options['relationships']['field_part_model_tid']['table'] = 'field_data_field_part_model';
$handler->display->display_options['relationships']['field_part_model_tid']['field'] = 'field_part_model_tid';
$handler->display->display_options['relationships']['field_part_model_tid']['label'] = 'Compatible Models';
$handler->display->display_options['relationships']['field_part_model_tid']['required'] = TRUE;
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
/* Contextual filter: Taxonomy term: Term ID */
$handler->display->display_options['arguments']['tid']['id'] = 'tid';
$handler->display->display_options['arguments']['tid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['arguments']['tid']['field'] = 'tid';
$handler->display->display_options['arguments']['tid']['relationship'] = 'field_part_model_tid';
$handler->display->display_options['arguments']['tid']['default_action'] = 'not found';
$handler->display->display_options['arguments']['tid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['tid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['tid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['tid']['summary_options']['items_per_page'] = '25';
/* Display: Related Parts */
$handler = $view->new_display('panel_pane', 'Related Parts', 'panel_pane_2');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Related Parts';
$handler->display->display_options['display_description'] = 'Finds a list of parts that are related to the currently-viewed model.';
$handler->display->display_options['argument_input'] = array(
'tid' => array(
'type' => 'context',
'context' => 'entity:taxonomy_term.tid',
'context_optional' => 0,
'panel' => '0',
'fixed' => '',
'label' => 'Taxonomy term: Term ID',
),
);