How to Theme View output
| Project: | jCarousel Lite |
| Version: | 5.x-2.0-beta2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Any chance someone might know how to help me theme the view output of jCarousel-view? It's outputting fields as I can tell but I can't quite get the following (typical list theme) in my template file to work:
function phptemplate_views_view_user_tracker_blog($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;
$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'];
}
}
$items[] = _phptemplate_callback('views-user_tracker_blog', $vars);
}
if ($items) {
return theme('item_list', $items);
}
}"foreach ..." is where the problem starts I believe. The view in question does get outputted as view_user_tracker_blog as I can tell from firebug, and the fields are labeled a little differently - essentially missing the "list" in the tags.
[the following might be unecessary but..] Essentially I'm trying to print three things (imagefield, title and date) but with an if/else statement to print taxonomy if an image is not present. Then, I'm using taxonomy_image module to replace the taxonomy with an image related to the taxonomy - if no image has been uploaded to the imagefield. That way, there's always a uniform look to the view of items. Here's an example of what I would putting inside the user_tracker_blog.tpl.php:
<?php if ($field_image_fid) : ?> <?php print $field_image_fid?>
<?php else:?>
<a href="<?php print url("node/$node->nid"); ?>"><?php foreach (taxonomy_node_get_terms($node->nid) as $term) {
print taxonomy_image_display($term->tid, "alt='$term->name' title='$term->name'");
}?></a>
<?php endif; ?> Any help would be awesomely appreciated.
