<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
This is D6 code for the CCK API.<br>
In D7, you can use field_info_instances('node').<br>
<br>
foreach (field_info_instances('node') as $node_type =>
$instances) {<br>
foreach ($instances as $instance) {<br>
$field = field_info_field($field_name);<br>
drupal_set_message(t('node type: %node_type, name: %field_name,
label: %label, type: %type', <br>
array(<br>
'%node_type' => $node_type,<br>
'%field_name' => $field['field_name'],<br>
'%label' => $instance['label'],<br>
'%type' => $field['type'],<br>
))<br>
);<br>
}<br>
}<br>
<br>
<br>
Le 19/01/2011 16:28, nan wich a écrit :
<blockquote cite="mid:700267.18089.qm@web180311.mail.gq1.yahoo.com"
type="cite">
<style type="text/css"><!-- DIV {margin:0px;} --></style>
<div style="font-family: arial,helvetica,sans-serif; font-size:
12pt;">
<div>From the RealName module:</div>
<div><font face="Courier New, courier, monaco, monospace,
sans-serif" size="2"> $all_fields = content_fields(NULL,
$type);<br>
if ($all_fields) {<br>
foreach ($all_fields as $field_name =>
$field_attributes) {<br>
// If it's not the type we are looking for, then skip
the field.<br>
if ($field_attributes['type_name'] != $type) {<br>
continue;<br>
}<br>
switch ($field_attributes['type']) {<br>
case 'text':<br>
if ($field_attributes['multiple']) {<br>
drupal_set_message(t('The RealName module does
not currently support fields with multiple values, such as
@fld.', array(</font><a moz-do-not-send="true"
href="mailto:%27@fld%27"><font face="Courier New, courier,
monaco, monospace, sans-serif" size="2">'@fld'</font></a><font
face="Courier New, courier, monaco, monospace, sans-serif"
size="2"> => $field_name)), 'warning');<br>
}<br>
else {<br>
$selected = array_key_exists($field_name,
$current);<br>
$fields[$field_name] = array(<br>
'title' =>
$field_attributes['widget']['label'],<br>
'weight' => $selected ?
$current[$field_name] : 0,<br>
'selected' => $selected,<br>
);<br>
}<br>
break;</font></div>
<div><font face="Courier New, courier, monaco, monospace,
sans-serif" size="2"> case 'link':<br>
$links[$field_name] =
$field_attributes['widget']['label'];<br>
}<br>
}<br>
}<br>
else {<br>
drupal_set_message(t('The !type content type has no
fields to use.', array('!type' => $type)), 'error');<br>
}<br>
</font><br>
</div>
<p><font color="#ff007f" face="bookman old style, new york,
times, serif" size="4"><em><strong>Nancy</strong></em></font></p>
<p> </p>
<p><font face="arial, helvetica, sans-serif">Injustice anywhere
is a threat to justice everywhere. -- Dr. Martin L. King,
Jr.</font></p>
<div><br>
</div>
<div style="font-family: arial,helvetica,sans-serif; font-size:
12pt;"><br>
<div style="font-family: Courier
New,monaco,monospace,sans-serif; font-size: 10pt;"><font
face="Tahoma" size="2">
<hr size="1">
<b><span style="font-weight: bold;">From:</span></b>
Fernando Correa da Conceição
<a class="moz-txt-link-rfc2396E" href="mailto:fernando@jaguaribe.net"><fernando@jaguaribe.net></a><br>
<b><span style="font-weight: bold;">To:</span></b>
<a class="moz-txt-link-abbreviated" href="mailto:development@drupal.org">development@drupal.org</a><br>
<b><span style="font-weight: bold;">Sent:</span></b> Wed,
January 19, 2011 9:59:17 AM<br>
<b><span style="font-weight: bold;">Subject:</span></b>
[development] How to list fields and types<br>
</font><br>
I have a $node object, in this node there is some fields
(Drupal 7). The module works on all contents type, so i do
not know what fields the node have. I need to list all
fields from a node and get the type of field.<br>
Someone can show a example how to do this please?<br>
<br>
Thanks.<br>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>