Drupal 7 呈现分类法页面D7的自定义字段

Drupal 7 呈现分类法页面D7的自定义字段,drupal-7,taxonomy,Drupal 7,Taxonomy,假设我有一个名为“职务”的词汇表。此词汇表包含几个自定义字段 "JOB TITLES" (Vocabulary) | |-- name (Default Field) |-- description (Default Field) |-- reference_url (Custom Field) |-- help_link (Custom Field) 上面的词汇表包含两个自定义字段,我可以在添加或编辑分类术语时看到它们 我的问题是,如何在我的page.tpl上使用它们?如何使用ho

假设我有一个名为“职务”的词汇表。此词汇表包含几个自定义字段

"JOB TITLES" (Vocabulary)
 |
 |-- name (Default Field)
 |-- description (Default Field)
 |-- reference_url (Custom Field)
 |-- help_link (Custom Field)
上面的词汇表包含两个自定义字段,我可以在添加或编辑分类术语时看到它们


我的问题是,如何在我的page.tpl上使用它们?如何使用hook_page_preprocess()在template.php上访问它们?

不幸的是,我还没有找到一个好的解决方案。我暂时解决了,所以:

自定义字段:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
术语描述:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
其中$term为:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);

我重复一遍,上面的自定义字段解决方案不是最佳实践,而且也是不可预测的,因此请小心使用。

不幸的是,我还没有找到一个好的解决方案。我暂时解决了,所以:

自定义字段:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
术语描述:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
其中$term为:

$output = (isset($term->field_FIELDNAME['und'][0]['safe_value']))? $term->field_FIELDNAME['und'][0]['safe_value'] : '' ;
$output = filter_xss_admin($term->description);
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);

我重复一遍,上面的自定义字段解决方案不是最佳实践,而且也是不可预测的,因此请小心使用。

为了在术语页面底部显示文本,我在分类词汇表中添加了两个新字段(“字段\术语\标题”和“字段\术语\页脚”)。我发现它创建了一个相当笨拙的嵌套数组。这是我添加到page.tpl.php以显示它的内容

<?php if ( arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) ): ?>

    <?php $page_term = taxonomy_term_load(arg(2));
        if ($page_term->field_footer_heading) {
        print '<h2 class="block-title">'.($page_term->field_footer_heading['und'][0]['safe_value']).'</h2>';
        }
    ?>
    <?php $page_term = taxonomy_term_load(arg(2));
        if ($page_term->field_footer_text) {
        print '<div class="content">'.($page_term->field_footer_text['und'][0]['safe_value']).'</div>';
        }
    ?>

    <?php endif; ?>

为了在术语页面底部显示文本,我在分类词汇表中添加了两个新字段(“字段\术语\标题”和“字段\术语\页脚”)。我发现它创建了一个相当笨拙的嵌套数组。这是我添加到page.tpl.php以显示它的内容

<?php if ( arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) ): ?>

    <?php $page_term = taxonomy_term_load(arg(2));
        if ($page_term->field_footer_heading) {
        print '<h2 class="block-title">'.($page_term->field_footer_heading['und'][0]['safe_value']).'</h2>';
        }
    ?>
    <?php $page_term = taxonomy_term_load(arg(2));
        if ($page_term->field_footer_text) {
        print '<div class="content">'.($page_term->field_footer_text['und'][0]['safe_value']).'</div>';
        }
    ?>

    <?php endif; ?>