简体   繁体   English

drupal 7 taxonomy_vocabulary_machine_name_load未显示字段

[英]drupal 7 taxonomy_vocabulary_machine_name_load did not show the fields

I have created a vocabulary and listed terms within it, in D7. 我在D7中创建了一个词汇表并列出了其中的术语。 I have added a field named "Icon Color". 我添加了一个名为“图标颜色”的字段。 Now, within the view, I have added the code block as below which perfectly displayed the fields like tid, name, description but it did not show the field "Icon Color". 现在,在视图中,我添加了以下代码块,该代码块完美显示了tid,name,description等字段,但未显示“ Icon Color”字段。

<?php
   $name = 'Programme';
   $myvoc = taxonomy_vocabulary_machine_name_load($name);
   $tree = taxonomy_get_tree($myvoc->vid);
   foreach ($tree as $term) { 
   print_r($term); 
   }
?>

The fields are listed within the vocabulary as below: 这些字段在词汇表中列出如下:

在此处输入图片说明

You must load the taxonomy using term id by taxonomy term load function. 您必须通过分类法术语加载功能使用术语ID加载分类法。 Hope the below code helps you. 希望下面的代码对您有所帮助。

$name = 'YOUR_MACHINE_NAME';
$myvoc = taxonomy_vocabulary_machine_name_load($name);
$tree = taxonomy_get_tree($myvoc->vid);
foreach ($tree as $term) { 
  $term = taxonomy_term_load($term->tid);
  print_r($term);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM