How to get fields of certain content type in template file without writing iteration loops in tpls? Here I'm getting all fields of certain content type in my .tpl.php file with the help of hook_theme.

return theme('carousal', array('carousal' =&gt; $fields));


And my template file is something like this:

&lt;?php
global $fields;
foreach($fields as $key =&gt; $value){
echo $value['title'];
print render ($value['fields']['body']);
}
?&gt;


Now, what I want is, I don't wanna use foreach loop in my template file. And if possible, not even any php tags.

How far is it possible to render fields in template file without using any loop?

Can't we write only "BODY" and we get "body" field rendered itself automatically?

I don't know whether it's possible or not. If it's possible, kindly let me know the way out of this.
You can pass your $fields to a custom function. Run your logic or foreach loop in the custom function and pass the title,body values back. Thus you would not need to use the foreach loop in template file.

Here is some sample code if it helps.

$field_data = _my_function($fields);
$data = theme('carousal', array('carousal' =&gt; $field_data));
return $data;