Fix for Fix for theming views 2 field output

  1. function eieditions_preprocess_views_view_field(&$vars) {
  2.   $view  = $vars['view'];
  3.   $field = $vars['field'];
  4.   $row   = $vars['row'];
  5.  
  6.   if ($view->name == 'homepage_features' && $view->current_display == 'node_content_4') {
  7.  
  8.     // This is the only reliable way to find unique names for fields in rows
  9.     // containing custom fields.
  10.     $fields = array_keys($view->display_handler->get_handlers('field'));
  11.  
  12.     switch ($fields[$field->position]) {
  13.  
  14.       // 'nothing' is the figure field.
  15.       case 'nothing':
  16.         $node = node_load($row->node_node_data_field_banner_nid, $row->node_node_data_field_banner_vid);
  17.  
  18.         if (count($node->field_illustration)) {
  19.           // The node has illustration node references.
  20.           $illustration_node = node_load($node->field_illustration[0]['nid']);
  21.           // TODO: make this work for embedded images
  22.           $image = content_format('field_image', $illustration_node->field_image[0], 'wide16gold_default', $illustration_node);
  23.           $creator = content_format('field_creator', $illustration_node->field_creator[0], 'default', $illustration_node);
  24.           $publisher = content_format('field_publisher', $illustration_node->field_publisher[0], 'default', $illustration_node);
  25.         }
  26.         else {
  27.           // TODO: support decoration reference fields.
  28.         }
  29.  
  30.         $vars['output'] = theme('figure', $image, $creator, $publisher);
  31.         break;
  32.  
  33.       // 'nothing_1' is the author/publisher credit for the featured item.
  34.       case 'nothing_1':
  35.         $field_creator_value = $view->display_handler->get_handler('field', 'field_creator_value');
  36.         $field_publisher_value = $view->display_handler->get_handler('field', 'field_publisher_value');
  37.         $vars['output'] = '<div class="credit vcard">';
  38.         $vars['output'] .= '<span class="fn">'. $field_creator_value->render($row) .'</span>';
  39.         if ($field_publisher_value->render($row)) {
  40.           $vars['output'] .= '<span class="o">'. $field_publisher_value->render($row) .'</span>';
  41.         }
  42.         $vars['output'] .= '</div>';
  43.         break;
  44.     }
  45.   }
  46. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.