I need to print individual fields from the $content variable in node.tpl.php file in separate div tags. How do I do that and how do I find out what the field's names are?

  • Use dsm($node); to find the path to be specified for all pieces of data.
    – drupalmav
    Mar 13 '13 at 7:56

Try this

<?php print render($content['your_field_name']); ?> this will print that field value .

  • 1
    Yes but how do I find out what the name of the field is? May 3 '12 at 12:34
  • 1
    print_r($node); May 3 '12 at 12:35
  • 5
    or go to admin panel and your content type => managefields => see the machine names of fields , that will be available as your_field_name May 3 '12 at 12:38

enable Devel module and in node-{content-type}.tpl.php

    <?php dsm($node); ?>
    <?php dsm($content); ?>

you can see all $node fields and content fields

  • 1
    This doesn't print anything. May 3 '12 at 12:35
  • 1
    Make sure u have enabled devel module May 3 '12 at 12:44
  • <?php print $messages; ?> place this in your page.tpl.php May 3 '12 at 12:45
  • How to access this page on the front end node-{content-type}.tpl.php ?
    – pal4life
    Oct 7 '14 at 4:16

You can use the Devel module and use dpm($content) or kpr($content) functions in your node.tpl file. From there you can see all the names and render them the way you want.


The best way to find the fields available are :

  print render($content);

in your tpl file. This would display the list of fields available. You can remove these lines later. Then, to print your individual fields you can just do:

print render($content['field_blog_pic']); or

 print $title   

depending on your fields (user pictures, image fields, normal text and so on).


I use the Devel Module,to find the field name. It's very useful.

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.