Hi,

I've created a new content, type, and I would like to be able in my own module to read all the values of all the fields of a particular instance of that content type.

I googled a bit but am not sure of the answer, I've seen some custom code, and I would like to use an api if there is any that could do what I need.

I'm planning to provide a parameter (most probably the nodeid) or even one of the unique fields of this content type to uniquely identify the instance, thus I'm planning to write a function such as:

get_all_values_of_mycontenttype (uniquekeyid)
{
return $allfieldsoftheuniquekeyid;
}

Many thanks in pointing me in the right direction

Comments

nevets’s picture

How about we step back a step, what is the over all purpose of this module?

pureh2o’s picture

Hi nevets

The overall purpose is to be able to use an id and generate html code of a table with rows added like I explained here:
https://www.drupal.org/node/2549575

Thank you

nevets’s picture

Why not use the views module?

jackenmail’s picture

If you want to all data of your custom content type (mycontenttype), so please try with following code

$type = "mycontenttype"; // Machine name 
$nodes = node_load_multiple(array(), array('type' => $type)); 
foreach($nodes as $mycontenttype):
   print $mycontenttype->nid; 
   print $mycontenttype->title; 
endforeach;