Drupal 7 Is the a way to programmatically know the Fields in a Content Type?

716 views Asked by At

In Drupal 7, i need to Programmatically create the nodes, by using:

$node = new stdClass();
$node->type = "movie";

After, just this codes above, and lets assume i don't know what are the fields for it.

  • How can i get to know the fields and that field's structure for this Content Type?
  • (or) Can i echo out the fields inside a Content Type and its relations ?
1

There are 1 answers

0
danielson317 On

Your opening a pretty serious api up with this. The base command is:

$data=field_info_instances("node",$source_node_type);

Fields are tied to entities. the argument's here are you asking for the fields attached to the "node" entity and the second argument is for the "node type" referred to in entity speak as the "bundle"

But it's a rather involved api. Check out the documentation for the entire api here: http://api.drupal.org/api/drupal/modules%21field%21field.module/group/field/7