Ultimately, what I'm trying to do is create a table of businesses that offer certain services. I've made a vocabulary with terms (services) that a business could offer.

I'm using Views PHP to make each column in the table one of the terms in the vocabulary. If the business does offer the service, there will be a checkmark in that cell showing that they offer the service.

In Drupal 6, I was able to achieve this using Customfield. Here's my original post questioning it: http://drupal.org/node/1135090

I was successful in figuring it out, and here's the code that I was able to use:

<?php
$node = node_load($data->nid);
$terms = taxonomy_node_get_terms($node);


// make a new variable array

$tid=array();


// go through a loop and gathers the tids from $terms

foreach($terms as $key=>$value) {
    $tid[]=$value->tid;
}


// combines all the variables

$tid = implode(',', $tid);

// explode all the variables individually

$tid = explode(',',$tid);


// check to see if term ID is in the content
// change number to tid of the term

if (in_array("48", $tid)) {
 echo "Yes!";
}

?>

But, Drupal 7 has changed, and the code above does not work. I suppose my first question would be how to print out individually all the TIDs of a particular node. Any ideas?

Comments

johnv’s picture

That's difficult. You want an Exclusive Join, which does not seem to be possible in MySQL.
You could render the displa outpput as a pivot table, using each term as a column. But you won't see terms that aren't referenced.

Alain DG’s picture

Issue summary: View changes

Can this be achieved with another set of modules?
thank you

Liam Morland’s picture

Category: Task » Support request