With the following sample, we get a block with nodes which have the same term id as the actual node:

if ($type=='block' && arg(0) == 'node' && is_numeric(arg(1))){ 
$node=node_load(arg(1));
$terms = taxonomy_node_get_terms_by_vocabulary($node->nid, 3, 'mykey');
foreach($terms as $term){
$city = $term->tid;
}
return $city;
}

Here 3 is the vid of the desired vocabulary, while 'mykey' can be any property of the $node object, is optional and if omitted will result in 'tid' (see api reference).

Actually the foreach() is less than desired, although necessary: it keeps overwriting the same value so that only the last item of the array is kept - it may be that the last one is also the only one, which is just perfect in my case.

Comments

asb’s picture

Is this snippet supposed to be entered as default views argument, or should this work stand-alone in a PHP block?

Summit’s picture

I think it is ok to use it as stand-alone PHP block.
EDIT: I do not get it to work stand-alone, so may be it is a part of views?
Anyone knows how to show a CCK field, like imagefield of a node in a block with same term?
Thanks a lot in advance for your reply!
greetings,
Martijn