Php Drupal:视图-在标题中打印分类术语描述
我使用以下代码在views页面标题中打印分类术语Php Drupal:视图-在标题中打印分类术语描述,php,drupal,drupal-views,taxonomy,Php,Drupal,Drupal Views,Taxonomy,我使用以下代码在views页面标题中打印分类术语 <?php $view = views_get_current_view(); $term_name = array_pop($view->args); $term_name = str_replace('-', ' ', $term_name); $possible_terms = taxonomy_get_term_by_name($term_name); $term = $possible_terms[0]; print '&l
<?php
$view = views_get_current_view();
$term_name = array_pop($view->args);
$term_name = str_replace('-', ' ', $term_name);
$possible_terms = taxonomy_get_term_by_name($term_name);
$term = $possible_terms[0];
print '<div class="term-desc">';
print filter_xss_admin($term->description);
print '</div>';
?>
我遇到的问题是,它适用于所有有多个单词的术语,但对于只有一个单词作为术语名称的术语,它不会打印描述。试试看
$term = array_pop($possible_terms)
而不是
$possible_terms[0].
你也可以试着做一个
foreach($possible_terms as $key=>$term){
$desc = $term->description
}
如果这对做一件事没有帮助的话
var_转储(可能的条款);
查看您的数据结构