Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use node_load()?

Hi m a bit confused that how to retrieve node title by using this code

node_load($nid); $title=$nid->title;

i have done this coding in block and i wants to retrieve from node id for displaying image.that images are normally uploaded at the site by using filezilla and it has same name as the node title.i have tried many forms of node_load(),but i m failure.so please tell me right option for this. Thanks all.-Pranoti

like image 259
pranoti Avatar asked Dec 06 '22 01:12

pranoti


2 Answers

Here is the reference for node_load

http://api.drupal.org/api/function/node_load

It returns an object which is the node.

$node = node_load($nid); // $nid contains the node id
$title = $node->title;

Please get a good book on Drupal Module development to learn the fundamentals.

like image 78
Sid Kshatriya Avatar answered Dec 08 '22 03:12

Sid Kshatriya


Your question is a little confusing. Could you clean it up and explain better what you are trying to accomplish? In all events:

Node load takes either an numeric argument or an array of parameters to query, and returns a single node object. (As already mentioned, here's the API documentation: http://api.drupal.org/api/function/node_load).

Load with a numeric node id:

$nid = 55;
$node = node_load($nid);
$title = $node->title;

Load by querying on title:

$title = 'How to serve man';
$node = node_load(array('title' => $title));
$body = $node->body;
like image 35
David Eads Avatar answered Dec 08 '22 02:12

David Eads