我有这个片段,它显示了站点中属于特定词汇表的所有分类列表。我如何打印属于我实际加载的节点的术语,而不是打印整个列表?我有一个 Drupal 7 安装。
这就是我打印我所在节点的 id 的方式:<?php print $node->nid;?>
<?php
$vid = 11; //vocabulary id
$query = "SELECT tid, name, count
FROM (
SELECT td.tid AS tid, name, COUNT(td.tid) AS count
FROM taxonomy_term_data AS td
JOIN taxonomy_index AS tn
ON td.tid = tn.tid
JOIN node AS n
ON n.nid = tn.nid
WHERE td.vid = ". $vid ."
AND n.status = 1
GROUP BY td.tid
ORDER BY count DESC
) AS t
ORDER BY name ASC";
$result = db_query($query);
foreach($result as $term) {
if ($term->count > 0) {
echo l($term->name, "taxonomy/term/$term->tid").' ('.$term->count.')'.'<br/>';
}
}
?>