Drupal 7 Themeing - template.tpl.php vs template.php - variables I am interested in learning what disadvantage, if any, there are in calling variable fields directly within the template.tpl.php files.

Is it ok to place a field variable within the template.tpl.php file if doing it as simply as:

&lt;?php 
//--------------------------------
// COLOR
if(!empty($content['product:title']['#product']-&gt;field_taxonomy_color['und'][0]['taxonomy_term']-&gt;name)): ?&gt;
    &lt;div id="color-wrapper"&gt;
    &lt;?php
        $max_length = count($content['product:title']['#product']-&gt;field_taxonomy_color['und'])-1;
        for($x = 0; $x &lt;= $max_length; $x++){
            echo '&lt;div class="color"&gt;'. $content['product:title']['#product']-&gt;field_taxonomy_color['und'][$x]['taxonomy_term']-&gt;name .'&lt;/div&gt;';
        }  
    ?&gt;
    &lt;/div&gt;
&lt;?php endif; ?&gt;


My understanding is that this code should be placed a preprocess function and called into the tpl.php file such as:

TEMPLATE.PHP

function theme_preprocess_node(&amp;$variables) { $variables['color'] = ... }


TEMPLATE.TPL.PHP

&lt;?php echo $color; ?&gt;


If this is the case, how would i return all values of the loop from template.php into template.tpl.php?

---------EDIT---------
Should I create complex logic within its own field--template.tpl.php file, set the field to a variable in template.php and call upon the variable inside the node--template.tpl.php?  Would there be a problem with creating over a hundred field--template.tpl.php files?
The disadvantage is you leak a lot of PHP code processing Drupal inner structures to the template file.

I would preprocess $content in template.php to expose a simple array of strings as a custom variable:

$colors = $content['product:title']['#product']-&gt;field_taxonomy_color['und'];
$colorNames = Array();
for ($x = 0; $x &lt; count($max_length); $x++) {
  $colorNames[$x] = $colors[$x]['taxonomy_term']-&gt;name;
}
$variables['color_names'] = $colorNames;


Then the template code could be:

&lt;?php if ($color_names): ?&gt;
&lt;div id="color-wrapper"&gt;
  &lt;?php foreach ($color_names as $cn)
    print '&lt;div class="color"&gt;' . $cn  . '&lt;/div&gt;'; ?&gt;
&lt;/div&gt;
&lt;?php endif; ?&gt;