Drupal:如何手动打印分类图像

时间:2010-12-04 00:05:57

标签: php image drupal taxonomy vocabulary

以下是我使用Taxonomy Image打印每个特定词汇的分类图像的代码:

<?php
$vid = 19;
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
$new_terms = array();
if ($terms) {
    foreach ($terms as $term) {
    $term = taxonomy_image_display($term->tid) as $image);
    print '<div class="color">' . $image . '</div>';
    $new_terms[] = $image;
    }
}   
?>

1 个答案:

答案 0 :(得分:1)

您的代码已损坏。你的意思是:

<?php
$vid = 19;
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
$new_terms = array();
if ($terms) {
    foreach ($terms as $term) {
        $image = taxonomy_image_display($term->tid);
        print '<div class="color">' . $image . '</div>';
        $new_terms[] = $image;
    }
}   
?>

这是正确的PHP,应该可以正常工作。