I have an article that I've set to a variable like this:
$this_node = node_load($nid);
I've done a print_r on $this_node and this is what I get - it's pretty long, sorry:
stdClass Object
(
[nid] => 67572
[type] => imagevault
[language] =>
[uid] => 3
[status] => 1
[created] => 1303347600
[changed] => 1305662899
[comment] => 0
[promote] => 0
[moderate] => 0
[sticky] => 1
[tnid] => 0
[translate] => 0
[vid] => 67572
[revision_uid] => 1
[title] => Anne Jones
[body] =>
[teaser] =>
[log] =>
[revision_timestamp] => 1305662899
[format] => 2
[name] => pbreen
[picture] =>
[data] => a:0:{}
[field_pub_date] => Array
(
[0] => Array
(
[value] =>
[timezone] => America/Chicago
[timezone_db] => America/Chicago
[date_type] => date
)
)
[field_att_file] => Array
(
[0] => Array
(
[fid] => 59327
[uid] => 3
[filename] => KCJones.jpg
[filepath] => sites/default/files/images/KCJones.jpg
[filemime] => image/jpeg
[filesize] => 54806
[status] => 1
[timestamp] => 1304023490
[list] => 1
[data] => Array
(
[description] =>
)
)
)
[path] => imagevault/67572
[0] =>
[taxonomy] => Array
(
[264] => stdClass Object
(
[tid] => 264
[vid] => 15
[name] => Kimberly-Clark
[description] =>
[weight] => 0
)
[137] => stdClass Object
(
[tid] => 137
[vid] => 10
[name] => People
[description] =>
[weight] => 0
)
)
)
I know I can get certain values from the node like this:
$imagefile = array();
$imagefile['name'] = $this_node->field_att_file[0]['filename'];
Here's what I need to do, though (and I'm very new to Drupal so forgive me if this is really simple.) The article can, as shown, have multiple taxonomy terms. I need to treat a chunk of display code differently if the article has 137 as one of the taxonomy terms. How would I go about this?
Something like this, or is there a better way? (Don't even know if this way works yet; it probably won't since each tax term is an object, not an array.)
$this_tax = $this_node->taxonomy;
if (array_key_exists('137', $this_tax)) {
// Do stuff
}
if (isset($this_node->taxonomy[137])) { ...
should work too.