2010-06-07 94 views
7

列出CCK字段,以获取的内容类型的CCK字段列表,我希望能使用:如何通过内容类型在Drupal

drupal_get_schema('content_type_mycontenttype'); 

但省去了多个值的字段。有没有简单的电话来获得这样的清单?

回答

1

我用这样的事情之前做的CCK现场信息的快速列表的内容类型:

$mytype = 'article'; 
    $contentinfo = _content_type_info(); 
    $output .= "<ul>"; 
    foreach($contentinfo['fields'] as $field) { 
     if ($field['type_name'] == $mytype) { 
      $output .= '<li id="field-' . $field['field_name'] . '">' . $field['widget']['label'] . '<br>'; 

      if ($field['widget']['description']) { 
       $output .= $field['widget']['description'] . '<br>'; 
      }  

      $output .= '<ul> 
        <li>Content Types: ' . $field['type_name'] . '</li> 
        <li>Type: ' . $field['type'] . '</li> 
        <li>' . $field['field_name'] . '</li> 
       </ul>'; 
     } 
    } 
    $output .= '</ul>'; 
3

为Drupal 7,检查出field_info_instances函数检索的字段列表特定节点内容类型。

下面是一个示例用法,它将检索节点内容类型的所有字段。

$ my_content_type_fields = field_info_instances(“node”,“my_node_content_type”);

+1

感谢D7提示 – Varshith 2013-05-23 08:40:00