function content_taxonomy_views_argument_handler_taxletter in Content Taxonomy 5
Perform filtering by an argument (as term name) for field data stored via content taxonomy
1 string reference to 'content_taxonomy_views_argument_handler_taxletter'
- content_taxonomy_views_views_arguments in ./
content_taxonomy_views.module - Implementation of hook_views_arguments()
File
- ./
content_taxonomy_views.module, line 210 - Views Support for content_taxonomy
Code
function content_taxonomy_views_argument_handler_taxletter($op, &$query, $argtype, $arg = '') {
if ($op == 'filter') {
$field_name = substr($argtype['type'], 10);
}
else {
$field_name = substr($argtype, 10);
}
$field = content_fields($field_name);
$db_info = content_database_info($field);
$main_column = reset($db_info['columns']);
// The table name used here is the Views alias for the table, not the actual
// table name.
$table = 'node_data_' . $field['field_name'];
switch ($op) {
case 'summary':
$query
->ensure_table($table);
$query
->add_field($main_column['column'], $table);
return array(
'field' => $table . '.' . $main_column['column'],
);
break;
case 'sort':
break;
case 'filter':
$query
->ensure_table($table);
if ($argtype['options'] == '-1') {
$th_num = $query
->add_table('term_hierarchy', false, 1, array(
'left' => array(
'table' => $table,
'field' => $main_column['column'],
),
'right' => array(
'field' => 'parent',
),
));
$th_table = $query
->get_table_name('term_hierarchy', $th_num);
$td_num = $query
->add_table('term_data', false, 1, array(
'left' => array(
'table' => $th_table,
'field' => 'tid',
),
'right' => array(
'field' => 'tid',
),
));
$td_table = $query
->get_table_name('term_data', $td_num);
$query
->add_where($td_table . ".name = '%s'", $arg);
}
else {
if ($argtype['options'] == '1') {
$th_num = $query
->add_table('term_hierarchy', false, 1, array(
'left' => array(
'table' => $table,
'field' => $main_column['column'],
),
'right' => array(
'field' => 'tid',
),
));
$th_table = $query
->get_table_name('term_hierarchy', $th_num);
$td_num = $query
->add_table('term_data', false, 1, array(
'left' => array(
'table' => $th_table,
'field' => 'parent',
),
'right' => array(
'field' => 'tid',
),
));
$td_table = $query
->get_table_name('term_data', $td_num);
$query
->add_where($td_table . ".name = '%s'", $arg);
}
else {
$td_num = $query
->add_table('term_data', false, 1, array(
'left' => array(
'table' => $table,
'field' => $main_column['column'],
),
'right' => array(
'field' => 'tid',
),
));
$td_table = $query
->get_table_name('term_data', $td_num);
$query
->add_where($td_table . ".name = '%s'", $arg);
}
}
break;
case 'link':
break;
case 'title':
return check_plain($arg);
}
}