installation - Drupal 7 - Adding data in specific content type field -


currently building installation profile drupal 7. make multiple fields , create instances fields @ specific content type.

now add new node content type don't know how add data fields generated content type. has happen in installation profile in code , no explanation drupal self.

the node generated this:

$node          = new stdclass(); $node->title   = 'test title'; node_save($node); 

this not whole code of course give idea. add type, status, uid, title, promote, created, timestamp, sticky, format, language, teaser, body , revision $node. want add custom field data, has idea on how this?

something like...

$node = new stdclass(); $node->type = 'article'; $node->title = 'test title'; $node->language = language_none; node_object_prepare($node); // other properties...  // single cardinality $node->field_some_text_field[$node->language][0]['value'] = 'some value';  // multiple cardinality $node->field_some_entity_reference_field[$node->language][]['target_id'] = 123; $node->field_some_entity_reference_field[$node->language][]['target_id'] = 456;  node_save($node); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -