Skip to main content
added 139 characters in body
Source Link
Laxman13
  • 6.8k
  • 3
  • 30
  • 39

Each taxonomy term in a node also gives you the vocabulary id that it belongs to. So you could look through the terms to see if one matches the vocabulary id of your "Color" vocabulary and then display "It has color" when found.

An easy way to do this would be to use a loop:

<?php foreach ($node->taxonomy as $key => $term): {?>
  // Say the vocabulary id of "Color" is 10.
  <?php if ($term->vid == 10): {?>
    <div>
      <?php print "Itviews_embed_view('my-views', has'default', color";$args); ?>
    </div>
    // etc
    <?php break; ?>
  }<?php endif; ?>
}<?php endforeach; ?>

For reference, to access the vocabulary id of a single term:

$node->taxonomy[TERM_ID]->vid;

Where TERM_ID is the id of the taxonomy term.

Each taxonomy term in a node also gives you the vocabulary id that it belongs to. So you could look through the terms to see if one matches the vocabulary id of your "Color" vocabulary and then display "It has color" when found.

An easy way to do this would be to use a loop:

foreach ($node->taxonomy as $key => $term) {
  // Say the vocabulary id of "Color" is 10.
  if ($term->vid == 10) {
    print "It has color";
    break;
  }
}

For reference, to access the vocabulary id of a single term:

$node->taxonomy[TERM_ID]->vid;

Where TERM_ID is the id of the taxonomy term.

Each taxonomy term in a node also gives you the vocabulary id that it belongs to. So you could look through the terms to see if one matches the vocabulary id of your "Color" vocabulary and then display "It has color" when found.

An easy way to do this would be to use a loop:

<?php foreach ($node->taxonomy as $key => $term): ?>
  // Say the vocabulary id of "Color" is 10.
  <?php if ($term->vid == 10): ?>
    <div>
      <?php print views_embed_view('my-views', 'default', $args); ?>
    </div>
    // etc
    <?php break; ?>
  <?php endif; ?>
<?php endforeach; ?>

For reference, to access the vocabulary id of a single term:

$node->taxonomy[TERM_ID]->vid;

Where TERM_ID is the id of the taxonomy term.

Source Link
Laxman13
  • 6.8k
  • 3
  • 30
  • 39

Each taxonomy term in a node also gives you the vocabulary id that it belongs to. So you could look through the terms to see if one matches the vocabulary id of your "Color" vocabulary and then display "It has color" when found.

An easy way to do this would be to use a loop:

foreach ($node->taxonomy as $key => $term) {
  // Say the vocabulary id of "Color" is 10.
  if ($term->vid == 10) {
    print "It has color";
    break;
  }
}

For reference, to access the vocabulary id of a single term:

$node->taxonomy[TERM_ID]->vid;

Where TERM_ID is the id of the taxonomy term.