function theme_viewscarousel_display in Views carousel 5
Theme a carousel.
File
- ./
viewscarousel.module, line 183 - Enable the creation of dynamic loading carousel widgets with views.
Code
function theme_viewscarousel_display(&$view, &$nodes, $type) {
$path = drupal_get_path('module', 'viewscarousel');
drupal_add_js($path . '/jquery.jcarousel.pack.js');
drupal_add_js($path . '/viewscarousel.js');
drupal_add_css($path . '/viewscarousel.css');
$id = 'viewscarousel-' . $view->name;
$settings = viewscarousel_get_settings($view->name);
// If total_rows is not set, i.e. pager is set to FALSE or this is
// not a page view, get the view query in order to get total_rows.
if (isset($view->total_rows)) {
$total_rows = $view->total_rows;
}
else {
$query = views_build_view(queries, &$view, $view->real_args, $use_pager = false, $limit = 0, $page = 0, $offset = 0, $filters = NULL);
$total_rows = db_result(db_query($query['countquery']));
}
$settings += array(
'view' => $view->name,
'total' => $total_rows,
);
drupal_add_js(array(
'viewscarousel' => array(
$id => $settings,
),
), 'setting');
$fields = _views_get_fields();
$output = '';
if ($settings['first_node']) {
$node = array_shift($nodes);
$node = node_load($node->nid);
$output .= '<div class="viewscarousel-node" id="' . $id . '">';
$output .= node_view($node);
$output .= '</div>';
}
$output .= '<div class="viewscarousel viewscarousel-' . $settings['orientation'] . '" id="' . $id . '">';
$items = array();
foreach ($nodes as $node) {
$items[] = theme('viewscarousel_item', $fields, $node, $view);
}
$output .= theme('item_list', $items);
$output .= '</div>';
return $output;
}