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:
<?php
//--------------------------------
// COLOR
if(!empty($content['product:title']['#product']->field_taxonomy_color['und'][0]['taxonomy_term']->name)): ?>
<div id="color-wrapper">
<?php
$max_length = count($content['product:title']['#product']->field_taxonomy_color['und'])-1;
for($x = 0; $x <= $max_length; $x++){
echo '<div class="color">'. $content['product:title']['#product']->field_taxonomy_color['und'][$x]['taxonomy_term']->name .'</div>';
}
?>
</div>
<?php endif; ?>
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(&$variables) { $variables['color'] = ... }
TEMPLATE.TPL.PHP
<?php echo $color; ?>
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?