Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-beta2
Component:
Views Data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 May 2008 at 19:36 UTC
Updated:
14 Apr 2009 at 18:24 UTC
How do I use the list of of taxonomy terms of the current node in a view block as filter?
Also how do I create the view in the first place using the information?
Comments
Comment #1
merlinofchaos commentedYou'll have to use the PHP Code argument default setting and extract the taxonomy with PHP. Sorry, I don't have the time to tell you how to do this; there's LOTS in the snippets and you can probably find some support in the forums for at least extracting the terms, but that's beyond the scope of what I'm prepared to spend time on.
Comment #2
chandrabhan commentedI have found this code snippet.
$tids = '';
if($type == 'block' && arg(0) == 'node' && is_numeric(arg(1) ) ){
$vid = 2; // this is the vocabulary id to search through...
$terms = taxonomy_node_get_terms_by_vocabulary(arg(1), $vid);
foreach($terms as $term){
$tids[] = $term->tid;
}
$tids = implode('+', $tids);
}
return array($tids);
It says that i need to provide this using 'Argumrnt handling code' field in my view. But i cant seem to find that in views 2.0. Could you please help?
Comment #3
merlinofchaos commentedIn the argument settings, set the default action to 'Provide default argument'.
Then set the argument default to PHP code.
One difference between Views 1 and Views 2 is that in Views 1, you d set all the arguments at once. In Views 2, however, each argument is its own PHP snippet. So instead of returning an array, as above, you'll return just the argument.
Changing return array($tids) into return $tids should do the trick.
Comment #4
chandrabhan commentedComment #5
okday commentedHi,
i've tried this code but is doesn't work..
$tids = '';
if($type == 'block' && arg(0) == 'node' && is_numeric(arg(1) ) ){
$vid = 2; // this is the vocabulary id to search through...
$terms = taxonomy_node_get_terms_by_vocabulary(arg(1), $vid);
foreach($terms as $term){
$tids[] = $term->tid;
}
$tids = implode('+', $tids);
}
return $tids;
I have changed my VID to the correct vocaburary id.
someone have a new code?
thanks.
Comment #6
jastraat commentedCheck this out:
http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-cre...