Using views to build a block which shows the nodes holding the same terms as the current node(node/NID)

Events happening in the community are now at Drupal community events on www.drupal.org.
summit's picture

Hi,

I am trying to learn views like this one: http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-cre...
It looks like this view should work on a node/NID page, but I tried and could only get it to work correct on term/TID pages.
Is this correct?

The phpcode of the term argument is:

$node = node_load(arg(1));
if ($node && $node->taxonomy) { foreach($node->taxonomy as $term) {$terms[] = $term->tid;
} return implode('+' , $terms);
} else { return;
}

I would very much like to make a view like this, but then on the node/NID page and then a block of all nodes which have the same terms as the current node/NID
Thanks a lot in advance for your assistance!
Greetings, Martijn

Comments

See

Hi, I solved it myself..I had

summit's picture

Hi, I solved it myself..I had to reverse the stuff, aso first argument is the NID and second argument is the taxonomy argument. My enhanced argument code is:

if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node=node_load(arg(1));
      foreach($node->taxonomy as $term) {$terms[] = $term->tid;
return implode('+' , $terms);
}} else { return false;
}

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: