I'm using CCK + CCK image field module right now and I pretty happy with its features.

But, I want to customize my theme and have content available where I want it.

my CCK content type is called: CARTOON and it contains 3 fields


- title (text field)
- cartoon_image (image field)
- cartoon_text (text field)

Wow, my content is uploaded at once with all these 3 fields filled out, SO I have a title, an image, and a text below the image. Now the problem is, I want to get somehow the value of this cartoon_image field, so that I can use it no matter where in my template.

does anyone know how to get this value?


markhope’s picture

Info about theming CCK nodes here:

Creating a template

To quote from that page...
"A logical question at this point is how do you know what fields are available to use. Here is a tip that will help you design your theme. Add the following code to the very end of the template:"
<code><?php print_r($node); ?>

This will print to the page all available variables from your CCK type.


jorre’s picture


I know how to print all those variables, but my question is: how to read these?

[field_colum_cartoonimage] => Array
[0] => Array
[fid] => 21
[title] =>
[alt] =>
[nid] => 33
[filename] => BOrattenvergif.jpg
[filepath] => files/BOrattenvergif.jpg

-> I need this filename variable...
I already tried several things, but can't get that value...

I need the exact syntax and that's what I don't havE..


patrickharris’s picture

Try something like <?php print $node->field_colum_cartoonimage[0]['filename']; ?>.

jorre’s picture

I'll try this out later tonight and will get back to you, thanks already!


jorre’s picture

unfortunately, this doesn't print anything :(


patrickharris’s picture

and use <?php print_r($node); ?>. This will give you a list of variables. Then use the format I gave you to print the values you are after. Maybe try <?php print $node->field_colum_cartoonimage[0]['value']) ?>. You might find the variable is called something slightly different to the example you gave me - perhaps "colum" is spelt "column"?

markhope’s picture

What about:
<?php print $field_colum_cartoonimage['view'] ?>
<?php print $field_colum_cartoonimage['value'] ?>

or if you have multiple $field_colum_cartoonimage:

 <?php foreach ($field_colum_cartoonimage as $cartoonimage) { ?>
<dd> <?php print $cartoonimage['view'] ?> </dd>
<?php } ?>
redvespa’s picture

Looking at this post (I don't have an answer for the question sorry) I started wondering, what is the difference between array['view'] and array['value'] ? These aren't php terms are they? This is drupal specific meaning.

sbefort’s picture

array['view'] is filtered and safe to display.

array['value'] is raw and could contain code. You probably don't want to display this.

anotherdave’s picture

Since I stubbled across this thread when looking for the variable I wanted, I thought I might as well post here after finding it.

The code below worked for me for calling a field I have given the name of "section".

<?php print $node->field_section[0]['value'] ?>

~ Dave

thomasmurphy’s picture

YOu're THE Dave, thanks for that post

ooz’s picture

...also in blocks?

I need to display the CCK-field-data of a book-coverpage in a block on all its subpages. I posted this here: http://drupal.org/node/260594
Any idea how to do this?

m4manas’s picture

It does work i believe its combination of object at top level and then array below.

johnmcauley’s picture

Can anybody tell me how to do this with a filefield?



johnmcauley’s picture

This will do it:


Pratheep’s picture

Thanks a lot anotherdave for posting your find. It works.

valuebound’s picture

thank you i tried same its working but...its displaying all my content including images,text,link together. where can i get those variables individually?
Thank you Dave

er.bhagwat’s picture

I am using webform to create a page.it contains a field Image path (Type = File)
When i attach a file(ex: homepage-banner.jpg) and submit it
in the data base value which is stored is:

a:5:{s:8:"filename";s:19:"homepage-banner.jpg";s:8:"filepath";s:40:"files/webform/upload/homepage-banner.jpg";s:8:"filemime";s:10:"image/jpeg";s:8:"filesize";i:48792;s:6:"source";s:5:"image";} Banner

How Can Fetch path From This.

Please Help Me.

franckweb’s picture

I got here looking for a way to print a drupal node variable but I cant seem to get it right. Maybe you guys can give me a hand.

When doing print_r ( $node->content[field_fechanacimiento] )

I get this:

Array ( [#type_name] => autor [#context] => full [#field_name] => field_fechanacimiento [#post_render] => ... etc etc

How can I print the field_name?? I get confused by the "#" sign.


Sagar Ramgade’s picture

you do need to use the # sign i prefer using the devel (http://drupal.org/project/devel) module to get the variables, you can use dev load tab to find out a particular element.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

saurabh.bhambry’s picture

Sorry if this question comes across as stupid to anyone .. but I wanted to know where I can find a comprehensive list of the attributes that a field may take. By attribute I mean for the field named section $node->field_section[0]['value'] .. has ['value'] as its attribute and this can be changed to ['view']. Similarly what are the other attributes can be used. I tried searching the API but couldn't find what I was looking for. Thanks for your help

flavio_tito’s picture

...saurabh.bhambry's request.