0

I would like to create a customized view and search page by writing my own module because I believe that Views is unable to do what I want. This requires me to write my own SQL queries, as well. Is there an API call I can use to get all the data and values about a specific node? For example, if I had a content type that asked for your first name and last name:

$values = get_node($nid)

and $values would end up looking something like:

$values['first_name'];
$values['last_name'];

Right now, it seems that all the fields and values are in their own tables, which makes it a nightmare in writing my SQL query to gather all data about the particular node.

3

You can use node_load() function.

eg:

 $node = node_load(nid); //you will get all fields values of particular node
 print_r($node); 
| improve this answer | |
  • for better formatting print "<pre>"; print_r ($vars); print "</pre>"; or you can also use debug($node); – undersound Oct 19 '12 at 8:38
  • Thank you!!!! I knew the Drupal developers would think of this! – user785179 Oct 19 '12 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.