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.– drupalmavMar 13, 2013 at 7:56
5 Answers
Try this
<?php print render($content['your_field_name']); ?>
this will print that field value .
-
1
-
1
-
5or 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, 2012 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
-
1
-
-
How to access this page on the front end node-{content-type}.tpl.php ?– pal4lifeOct 7, 2014 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 :
<?php
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).