An Override for theme_slideshow

Events happening in the community are now at Drupal community events on www.drupal.org.
TKS's picture

Just wanted to share a quick theme override that others might find useful.

For a group blog site we've been building (http://www.newamerica.net/blog), the Slideshow module is a great way to give users an easy way to drop images into their posts. The only problem was that, more often than not, someone would decide to post only one image -- which results in an unnecessary header of "Previous | Image 1 of 1 | Next".

The following override, when dropped into template.php, modifies the class for the header div so that it's specific to the number of photos. That way, one can add a "display: none" to the theme's CSS for .slideshow-header-1.

// ==================== Override of theme_slideshow Function ====================
// ===== Gives us a css class to hide prev/next links for single-image slideshows

function phptemplate_slideshow($element) {
  $slideshow = $element['#slideshow'];
  $status = $element['#slideshow']['status'];

  drupal_add_js(drupal_get_path('module', 'slideshow') .'/slideshow.js');
  drupal_add_css(drupal_get_path('module', 'slideshow') .'/slideshow.css');
  drupal_add_js(array('slideshow' => $slideshow['settings']), 'setting');

  $output = (isset($element['#prefix']) ? $element['#prefix'] : '') .'<div'. drupal_attributes($element['#attributes']) .'>';
  $output .= '<div class="header slideshow-header-' . $status['total'] . '">';
  $output .=   l(t('Previous'), $slideshow['url'], array('class' => 'previous'), 'slide='. $status['previous']) .' | ';
  $output .=   t('Image !current of !total', array('!current' => '<span class="current">'. $status['current'] .'</span>', '!total' => '<span class="total">'. $status['total'] .'</span>')) .' | ';
  $output .=   l(t('Next'), $slideshow['url'], array('class' => 'next'), 'slide='. $status['next']);
  $output .= '</div>';
  $output .= '<img class="image" src="'. $slideshow['image'] .'" />';
  $output .= '<span class="title">'. check_plain($slideshow['title']) .'</span>';
  $output .= '</div>'. (isset($element['#suffix']) ? $element['#suffix'] : '');

  return $output;
}

A simpler option, obviously, would be to tell people, "Don't post single-image slideshows!" But giving folks a single process for posting images is nice, and Slideshow's captions are a great feature in their own right. So for what it's worth -- hope others find it useful.

Slideshow

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: