Hi all,

I used node_load and get an object $myNode as below:

stdClass Object
(
    [nid] => 37
    [vid] => 37
    [type] => feedback
    [status] => 1
    [created] => 1223475817
    [changed] => 1223475818
    [comment] => 2
    [promote] => 0
    [sticky] => 0
    [revision_timestamp] => 1223475818
    [title] => 28
    [body] => fdsafdsa
f
dsa
fdsafd
    [teaser] => fdsafdsa
f
dsa
fdsafd
    [log] => 
    [format] => 1
    [uid] => 3
    [name] => client1
    [picture] => 
    [data] => a:0:{}
    [path] => work-report-feedbackinstructions/37
    [last_comment_timestamp] => 1223475818
    [last_comment_name] => 
    [comment_count] => 0
    [taxonomy] => Array
        (
            [7] => stdClass Object
                (
                    [tid] => 7
                    [vid] => 2
                    [name] =>  Return to Vendor
                    [description] => 
                    [weight] => -4
                )

        )

    [files] => Array
        (
            [30] => stdClass Object
                (
                    [fid] => 30
                    [nid] => 37
                    [filename] => 520.jpg
                    [filepath] => files/520.jpg
                    [filemime] => image/jpeg
                    [filesize] => 28526
                    [vid] => 37
                    [description] => 520.jpg
                    [list] => 1
                )

        )

)

I know we can use $myNode->title to show the title, but how to show taxonomy name (Return to Vendor) and the file name (520.jpg).

I am a newbie to drupal and php, thanks in advance.

Comments

sethlbrown’s picture

So if you've done this already $mynode = node_load($nid);

You will just traverse the object down through its arrays --

print $mynode->taxonomy[7]['name']; //will return ' Return to Vendor'

print $mynode->files[30]['filename']; //will return '520.jpg' also consider returning the path though you will need a '/' if you use relative path

Hope that helps!

Seth Brown
Blue Tent Marketing
Lullabot Alum

cybershan’s picture

It works now, thank you very much. :)