function theme_jcarousel($items = array(), $options = array(), $skin = 'tango', $skin_path = NULL, $id = 'jcarousel') {
    $name = form_clean_id($id);
    jcarousel_add('#'. $name, $options, $skin, $skin_path);
    $output = '<ul id="'. $name .'" class="js-hide jcarousel-skin-'. $skin .'">';
    foreach ($items as $item) {
      $output .= '<li>'. $item .'</li>';
    }
    $output .= '</ul>';
    return $output;
}

should perform a check before attempting to render:


function theme_jcarousel($items = array(), $options = array(), $skin = 'tango', $skin_path = NULL, $id = 'jcarousel') {
  if ($items[0]) {
    $name = form_clean_id($id);
    jcarousel_add('#'. $name, $options, $skin, $skin_path);
    $output = '<ul id="'. $name .'" class="js-hide jcarousel-skin-'. $skin .'">';
    foreach ($items as $item) {
      $output .= '<li>'. $item .'</li>';
    }
    $output .= '</ul>';
    return $output;
  }
}

Comments

quicksketch’s picture

I don't particularly agree with this change. It's possible that you'd actually want an empty <ul> added to the page in the situation that you were loading these items through JavaScript earlier in the page load. If we're having a problem of calling this with an empty list of items, we should do the check prior to calling theme('jcarousel').

quicksketch’s picture

Project: jCarousel » Views carousel
Version: 6.x-1.x-dev » 6.x-2.x-dev

Moving this to Views Carousel, since it's the module rendering the empty carousel incorrectly.

digitalfrontiersmedia’s picture

Agreed. Good call.