2

I have this code which gives me the number of terms on a node

 $count = count($node->taxonomy)

Is there a way i can restrict this to VID. i only want to get the count for a specific vocabulary.

Oh yeah the site is in D5

here is a link to the page http://national.thedelimagazine.com/8947/delis-austin-issue-2012-pdf-version-available

1 Answer 1

2

I don't have a D5 system handy, but this would do it in D6:

$count=0;
foreach ($node->taxonomy as $t) {
  if ($t->vid==VID_IN_QUESTION) {
    $count++;
  }
}

and it "should" be the same in D5, but I've said that a lot about D7 and D6 :) If not,

drupal_set_message('<pre>' . print_r($node->taxonomy,true) . '</pre>');

should give you the object information you need to modify above to count. If that doesn't work,

$foo=taxonomy_node_get_terms_by_vocabulary($nid, $vid);
$count=count($foo);

certainly is a roundabout way of getting them if you already have the node loaded.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.