DrupalBin
Submit Code
About
Recent Posts
css path
11 min 46 sec
ago
Fix for Code
4 hours 11 min
ago
Fix for Code
4 hours 17 min
ago
Fix for Code
4 hours 25 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for Argument handler for terms restricted to vocabulary
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
function taxonomy_combination_views_arguments() { $arguments = array(); foreach (taxonomy_get_vocabularies() as $vocabulary) { if($vocabulary->taxonomy_combination_show) { $arguments['tc_taxinvoc_' . $vocabulary->vid] = array( 'name' => t('Taxonomy: Term Name from ' . $vocabulary->name), 'handler' => 'views_handler_tc_taxinvoc', 'help' => t('The argument will filter by a taxonomy term name from the vocabulary ' . $vocabulary->name), ); } } return $arguments; } function vocab_id_from_typename($typename) { return end(explode('_', $typename)); } function views_handler_tc_taxinvoc($op, &$query, $argtype, $arg = '') { static $field = NULL; /* drupal_set_message($op); echo "\n<br>op<br>\n"; echo "$op<br>\n"; echo "query<br>\n"; print_r($query); echo "argtype<br>\n"; print_r($argtype); echo "arg<br>\n"; print_r($arg); echo "<br>vocab id would be:<br>"; echo vocab_id_from_typename($argtype);*/ echo "<br>\n"; echo $op; echo "<br>\n"; switch($op) { case 'summary': //$argtype has typename //summary for the second one won't work $tnum = $query->add_table('term_data', true); $tablename = $query->get_table_name('term_data', $tnum); $len = intval($arg); $field = $fieldinfo['field'] = ($len <= 0 ? "$tablename.name" : "LEFT($tablename.name, $len)"); $fieldinfo['fieldname'] = 'letter'; $query->add_field('tid', $tablename); $query->add_where('%s.name IS NOT NULL', $tablename); $vid = vocab_id_from_typename($argtype); $query->add_where('%s.vid = %d', $tablename, $vid); return $fieldinfo; break; case 'sort': //no typename //this looks ok, sorts summary by name. $query->add_orderby('', $field, $argtype, 'letter'); break; case 'filter': //$argtype['type'] has typename $len = intval($argtype['options']); $tnum = $query->add_table('term_node'); $tablename = $query->get_table_name('term_node', $tnum); $tnum = $query->add_table('term_data', true, 1, array('left' => array('table' => $tablename, 'field' => 'tid'), 'right' => array('field' => 'tid'))); $tablename = $query->get_table_name('term_data', $tnum); $vid = vocab_id_from_typename($argtype['type']); $query->add_where($tablename . '.vid = %d', $vid); if ($len <= 0) { $query->add_where("%s.name = '%s'", $tablename, $arg); } else { $query->add_where("LEFT(%s.name, $len) = '%s'", $tablename, $arg); } break; case 'link': //$argtype has typename //this is fine return l($query->letter, "$arg/$query->letter"); case 'title': //$argtype has typename //I guess this is fine too, for now. return check_plain($query); } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.