【发布时间】:2013-12-06 11:26:30
【问题描述】:
出于各种原因,我使用作者的分类术语。每个博客节点都有一个术语参考字段 - field_authors - 列出一个或多个作者。我想做的是显示页面中列出的每个作者的术语描述。我的在线搜索得到了以下代码,我将其放在博客文章标题之后的 node--blog.tpl.php 中。
<?php
$vid = taxonomy_vocabulary_machine_name_load("authors")->vid;
$terms = taxonomy_get_tree($vid, 0, null, true);
$term_count = count($terms);
for ($i = 0; $i < $term_count; $i++) {
$name = $terms[$i]->name;
$id = $terms[$i]->tid;
$description = $terms[$i]->description;
?>
<div id="<?php print $id; ?>" class="taxonomy-description">
<?php print $description; ?>
</div>
<?php } ?>
正如您可能知道的那样,它会打印词汇“作者”的所有分类术语描述。我想只显示该页面中列出的术语(作者)的描述。
我还想到可能有更好的方法来实现这一点。因此,任何更好的建议将不胜感激。
【问题讨论】:
标签: php drupal drupal-7 drupal-theming