I'm assuming this requires some kind of overriding of the theme system...but basically, I want the list generated by the Views module (when you select View Type to be "List View") to be inline. The HTML such a view generates is:

<div class="content"><div class="view view-associated-art-creator"><div class="view-content view-content-associated-art-creator"><div class="item-list"><ul><li><div class="view-item view-item-associated-art-creator"><div class="view-field view-data-node-title"><a href="/node/2">Jennifer photo</a></div></div>
</li><li><div class="view-item view-item-associated-art-creator"><div class="view-field view-data-node-title"><a href="/node/5">Two Cats</a></div></div>
</li><li><div class="view-item view-item-associated-art-creator"><div class="view-field view-data-node-title"><a href="/node/1">Blue painting</a></div></div>
</li></ul></div></div><div class="more-link"><a href="/">more</a></div></div>
</div>

So no matter how I style the li and ul tags...The many div tags created by the Views module will cause a line break. How can I configure it so that it outputs span tags instead of div?

Comments

ugerhard’s picture

Have you tried styling the div tags for this view with "display: inline"?

dnguyen’s picture

Actually, that does work...and will do for a quick fix...but if I have a more complicated view-list, where several fields are listed, and thus more div tags created, that seems like it'll clutter the stylesheet fast. But maybe that ends up being less work than overriding a theme.

Anonymous’s picture

A tip on what div's need to be formatted.

dnguyen’s picture

I decided maybe outputting the Views-block as a table would work better...so same kind of question...I want to theme the table so that for this particular view-block, I want a table consisting of one row and multiple columns (as opposed to the default multiple rows, single column layout)...Which function would I override?

dnguyen’s picture

OK, I came up with my own hack, based on the following thread which discusses this in depth:
http://drupal.org/node/87367

Working off of this code, which I put in my template.php:

<?php
function mytheme_views_view_table($view, $nodes, $type) {
    $header = array();
    foreach ($view->field as $field) {
        $cell['data']=$field['label'];
        $cell['class']=$field['header'];
        $header[] = $cell;
    }
    $fields = _views_get_fields();    foreach ($nodes as $node) {
        $row = array();
        foreach ($view->field as $field) {
            $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
            $cell['class']='view-field-'.$field['queryname'];
            $row[] = $cell;
             
        }
        $rows[] = $row;
    }
      return theme('table', $header, $rows, array('class' => 'show-table'));
}
?>

I wrote this, which doesn't use any theme calls. So it's basically a cheap hack that I can do while I learn the ins and outs of the theming system:

<?php
function MYTHEME_views_view_table_NAMEOFVIEW($view, $nodes, $type) {
	$output ="";
	
    $fields = _views_get_fields();    
  
	
	$output .="<table><tr>";
    foreach ($nodes as $node) {
      
      	$output .= "<td>";
        foreach ($view->field as $field) {
            $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
            $cell['class']='view-field-'.$field['queryname'];
     	
   			$output .= "<div class=\"". $cell['class']. "\">". $cell['data']. "</div>";
             
        }
        $output .="</td>";
        
     
    }
    $output .="</tr></table>";
    return $output;


}
?>

Hopes this help other Drupal learners.