[support] views bonus grid view question

sander-martijn lists at severeddreams.com
Wed Nov 21 19:02:46 UTC 2007


Hi,

I have a view that displays a listing of photo galleries with thumbnails 
using the bonus grid view.  The photos for the gallery upload in a 
rather unreliable manner so when displaying the gallery I am using a 
usort() function to sort the photos alphabetically by name - this way it 
doesn't matter how they upload as long as the client names them 
correctly.  This is working fine in the galleries, but in the bonus grid 
view it is still displaying another photo in the thumbnail - i'm not 
sure if it's in order of upload (which is random since the uploading is 
happening in bulk and asynchronously) or what, but I would like to have 
it sorted alphabetically by name.  I can't figure out where to set this 
- I looked in views settings and also in the theming function in my 
template.php.  The latter is likely where it needs to go but I'm not 
sure which variable contains the images.  Below is the function which 
started as generated from the views theming wizard and has been modified 
since.  Anyone know which of these obtusely named variables represents 
the thumbnail image?

function phptemplate_views_bonus_view_grid_photo_gallery($view, $nodes, 
$type) {
  $fields = _views_get_fields();

  $taken = array();
 
  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = node_load($node->nid);
    $vars['view_fields'] = $view->field;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
     
      $vars[$name] = views_theme_field('views_handle_field', 
$field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $attrs = array();
    $attrs["onClick"] = "return showPhotos('" . 'node/'.$node->nid . "')";
    $vars['title'] .= '  | '. l('View Gallery »', 
'node/'.$node->nid, $attrs, null, null, false, true);
    $items[] = _phptemplate_callback('views-list-photo_gallery', $vars);
  }
  if ($items) {
    return implode($items);
  }
}


More information about the support mailing list