I use views module in my website (built in drupal-7). I have a custom theme. I have set a views-view-fields--XX.tpl.php like follows.
<?php /**`
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
* - $field->wrapper_suffix: The closing tag for the wrapper.
* - $field->separator: an optional separator that may appear before a field.
* - $field->label: The wrap label text to use.
* - $field->label_html: The full HTML of the label to use including
* configured element type.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>
<?php foreach ($fields as $id => $field): ?>
<?php if ($id == 'field_voti'):?>
<div class="uniscicampischeda">
<?php endif; ?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<?php print $field->wrapper_prefix; ?>
<?php print $field->label_html; ?>
<?php print $field->content; ?>
<?php print $field->wrapper_suffix; ?>
<?php if ($id == 'distance'): ?>
</div>
<?php endif; ?>
<?php endforeach; ?>`
"
in order to insert some fields into a new div with a specific class.
With firebug I see the following:
<td class="col-1 col-first vistacomplessiva">
<div class="views-field views-field-title nomeattivita">..</div>
<span class="views-field views-field-name">..</span>
<span class="views-field views-field-last-updated">..</span>
<div class="views-field views-field-field-foto">..</div>
<div class="views-field views-field-body descrizione">..</div>
<div class="uniscicampischeda">..</div>
</td>
All that I want to do now is to have the div with class="uniscicampischeda" before the div with class="views-field views-field-field-foto", so that with css I will give the right attributes (I want class "uniscicampischeda" with float=right attribute) HOw can I do that? do I have to write some code into views-view-fields--XX.tpl.php file? How? Can anybody help me? Thanks.