views:

79

answers:

2

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

+1  A: 

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.

Sid NoParrots
Your example repeats the post, mate.
David Eads
`node_load($nid); $title=$nid->title` He is doing title from $nid and not on $node.
Sid NoParrots
The -1 was not necessary man. It was a typo.
Sid NoParrots
I downvote incorrect comments so the commenter will fix them. Upvoted now.
David Eads
no hard feelings. But sometimes a simple comment will be sufficient too :-)
Sid NoParrots
@Noparrots Thanks sir i forgot to pass argument....:)
pranoti
+3  A: 

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;
David Eads
@David Thanks sir i forgot to pass argument....:)
pranoti