开发者

Display a text snippet if one of the taxonomy terms is 'green'?

开发者 https://www.devze.com 2023-01-12 19:01 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消