HTML 在词汇表中打印分类术语

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HTML 在词汇表中打印分类术语相关的知识,希望对你有一定的参考价值。

<?php
$listlength = 99; // number of terms to show.

$vocabulary_id = 18; // VID of the vocabulary that you need to index

$result = db_query_range(db_rewrite_sql("SELECT d.tid, d.name, MAX(n.created) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE d.vid = $vocabulary_id AND n.status = 1 GROUP BY d.tid, d.name ORDER BY name ASC"), 0, $listlength);

$items = array();
while ($category = db_fetch_object($result)) {
    $items[] = l($category->name .' ('. $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />';
  }

print theme('item_list', $items);
?>

PHP Drupal打印与节点关联的词汇表和术语

In template.php

<?php
function mythemename_taxonomy_links($node, $vid) {

//if the current node has taxonomy terms, get them
  if (count($node->taxonomy)):

    $tags = array();
     foreach ($node->taxonomy as $term) {
       if ($term->vid == $vid):
          $tags[] = l($term->name, taxonomy_term_path($term));
          endif;
}
    if ($tags):
//get the vocabulary name and name it $name
        $vocab = taxonomy_get_vocabulary($vid);
        $name = $vocab->name;
        $output .= t("$name") . ": " . implode(' | ', $tags);
    endif;

  endif;

     if ($output):
       return $output;
     endif;

}
?>

In page.tpl.php

<?php
$nid = arg(1);
print yourthemename_print_terms($nid);
?>

以上是关于HTML 在词汇表中打印分类术语的主要内容,如果未能解决你的问题,请参考以下文章

HTML 获取词汇表的分类术语

Drupal 7 在视图中获取分类术语列表

PHP Drupal打印与节点关联的词汇表和术语

获取词汇表的分类术语

Drupal打印与节点关联的词汇表和术语

分类法:***术语视图?