I want to be able to show or hide a text snippet on a node based on whether or not it was tagged with a specific taxonomy 开发者_StackOverflow社区term.
Something along the lines of:
if (term('green')) {
echo"this is green";
}
else {
echo "not green";
}
What is the Drupal way of doing this?
Assuming from your example that you're working from inside of node.tpl.php, and that you have a single very specific term in mind:
You can access $taxonomy->taxonomy_term_YourTermID
from within your node.tpl.php file, and test based on that.
If you'd like a more abstract solution, I'd recommend installing the devel module and building a function in your template.php
files based on what shows up under the 'Devel' tab in the relevant node.
精彩评论