Drupal 6:基于两个分类术语的 PHP 打印
如果节点有两个特定术语,我尝试使用 php 打印一些内容。
像这样的东西:
<?php
$terms = taxonomy_node_get_terms($node, $key = 'tid');
foreach ($terms as $term) {
if ($term->tid == 19) {
print '19';
}
if ($term->tid == 21) {
print '21';
}
}
?>
I am trying to use php to print something if the node has two specific terms.
Something like:
<?php
$terms = taxonomy_node_get_terms($node, $key = 'tid');
foreach ($terms as $term) {
if ($term->tid == 19) {
print '19';
}
if ($term->tid == 21) {
print '21';
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
taxonomy_node_get_terms()
返回一个数组,其中术语 ID 作为数组键。因此,要做类似您想要的逻辑的事情,您需要类似以下的内容:taxonomy_node_get_terms()
returns an array with the term IDs as the array key. So to do something like the logic you're wanting, you'd need something like the following: