This mini tutorial guides you through the steps required to create a view that:
- determines which taxonomy terms are associated with the current node such as a news item
- combines these terms into a default View Argument for Term ID
The result is a list with nodes which match at least one of the terms. So if your node is linked to term A and B, the list will contain items linked to A or to B.
Versions used: Drupal 6.10 with Views 6.x-2.3
- Create a View
- Add a Field Node > Title
- Remove the label and check: Link this field to its node
- If you like, add Sort criteria such as Node: Title with Sort order: Ascending
- Add an Argument Taxonomy > Term ID
- Action to take if argument is not present: Provide default argument
- Default argument type: PHP code
$node = node_load(arg(1));
if ($node->taxonomy) { // Does it have terms?
foreach ($node->taxonomy as $term) {
$terms[] = $term->tid;
}
return implode('+', $terms);
} else {
return;
}
- Validator: Default Validator
- Allow multiple terms per argument: checked
- Reduce duplicates: checked
