0

I have the following in use in a view, to allow me to swap the order of fields/rows for every other row:

<?php

/**
 * @file
 * Using this template to swap ordering of view rows in view block.
 *
 * - $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 if ($view->row_index %2 == 0) : 

  //image
   print $fields['field_image']->wrapper_prefix; 
   print $fields['field_image']->content; 
   print $fields['field_image']->wrapper_suffix; 

  //body
   print $fields['body']->wrapper_prefix; 
   print $fields['body']->content; 
   print $fields['body']->wrapper_suffix; 

  //mobile
   print $fields['nothing']->wrapper_prefix; 
   print $fields['nothing']->content; 
   print $fields['nothing']->wrapper_suffix; 


 else : 

  //body
   print $fields['body']->wrapper_prefix; 
   print $fields['body']->content; 
   print $fields['body']->wrapper_suffix; 

  //image
   print $fields['field_image']->wrapper_prefix; 
   print $fields['field_image']->content; 
   print $fields['field_image']->wrapper_suffix; 

//mobile
   print $fields['nothing']->wrapper_prefix; 
   print $fields['nothing']->content; 
   print $fields['nothing']->wrapper_suffix; 

endif; ?>

Filename: views-view-fields--founders.tpl.php

But now, whenever I click the "Rescan template files" button in the view, and sometimes just randomly, my primary navigation disappears and the "View, Edit" tabs change into a bulleted list. Is this the correct way to accomplish this desired end result? Is there a glaring omission in my tpl file code?

enter image description here

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.