This is the correct way to render out fields using the power of the Field API. This adheres to Drupal 7 standards, and will avoid issues with things like localisation.
By creating a custom node.tpl.php template for your content type you can output your fields as you wish using PHP.
Printing a field from your node
<?php print render($content['field_name_here']); ?>
Printing an element of a field
Say you want to render out just the image path (URI), rather than the full image syntax. If you use 'manage display' it will output the entire image with all of it's attributes (<img> tag along with src, width, height, alt...)
<?php // field_my_image is the name of the image field // using field_get_items() you can get the field values (respecting multilingual setup) $field_my_image = field_get_items('node', $node, 'field_my_image'); // after you have the values, you can get the image URL (you can use foreach here) $my_image_url = file_create_url($field_my_image[0]['uri']); print $my_image_url; ?>
Drupal version:

Justin Chevallier
Avid Drupal site builder & user for +10 years.
Comments
How in webform-submission-page.tpl add comment form
I hope webform-submission-page.tpl add comment form, such as a picture. But I do not know how to add comment form api in webform-submission-page.tpl
Adding comments to Webform submission page
To be honest I'm not too sure having never tried it myself. I did a quick search and turned up this link, hope it's of some help
Simply Gr8
I was trying hard to do the above thing for last 1 day.
Working fine for me.
Thank you.
Add new comment