Skip to main content
cleaned up, used proper code quote style, codified filenames etc, tweaked style and English
Source Link

Drupal likes to put spans<span> and divs<div> around every item. When you don't like that, you can override the PHP file that's causing this.

Look in the sites/all/modules/views/theme folder at: sites/all/modules/views/theme

views-view-list.tpl.php views-view-field.tpl.php views-view-fields.tpl the views-view-list.tpl.php, views-view-field.tpl.php and views-view-fields.tpl.php files.php

Look at thoseSave a copy of these files, make changes if you want to, and save them in your own templatetheme's 'templates' folder. Here Then you can edit the copies to strip code that makes spans, divs.. <span> and <div> etc.

  You canshould also rename the filename in your template map, if you just wantversion of these files according to do this for 1the view's template suggestions so the changes only affect your view.

I used this for a view where I wanted to make 3 columns, so I wanted the classes li_1, li_2 and li_3 (file: views-view-list.tpl.phpin file views-view-list.tpl.php)

<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

global $cnt_ul;
global $cnt_li;
$cnt_ul++;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
?>
<ul class="<?php print $classNameUl ?>">
<?php
foreach ($rows as $id => $row): $cnt_li++;
$className = (($cnt_li % 3) == 0)? "li_". $cnt_li ." last" : "li_". $cnt_li;
?>
<li class="<?php print $className ?>"><?php print $row; ?></li>
<?php endforeach; ?>
</ul>
<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

global $cnt_ul;
global $cnt_li;
$cnt_ul++;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
?>
<ul class="<?php print $classNameUl ?>">
<?php
foreach ($rows as $id => $row): $cnt_li++;
$className = (($cnt_li % 3) == 0)? "li_". $cnt_li ." last" : "li_". $cnt_li;
?>
<li class="<?php print $className ?>"><?php print $row; ?></li>
<?php endforeach; ?>
</ul>

Drupal likes to put spans and divs around every item. When you don't like that, you can override the PHP file that's causing this.

Look at: sites/all/modules/views/theme

views-view-list.tpl.php views-view-field.tpl.php views-view-fields.tpl.php

Look at those files, make changes if you want to, and save them in your own template folder. Here you can strip code that makes spans, divs...

  You can also rename the filename in your template map, if you just want to do this for 1 view.

I used this for a view where I wanted to make 3 columns, so I wanted the classes li_1, li_2 and li_3 (file: views-view-list.tpl.php)

<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

global $cnt_ul;
global $cnt_li;
$cnt_ul++;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
?>
<ul class="<?php print $classNameUl ?>">
<?php
foreach ($rows as $id => $row): $cnt_li++;
$className = (($cnt_li % 3) == 0)? "li_". $cnt_li ." last" : "li_". $cnt_li;
?>
<li class="<?php print $className ?>"><?php print $row; ?></li>
<?php endforeach; ?>
</ul>

Drupal likes to put <span> and <div> around every item. When you don't like that, you can override the PHP file that's causing this.

Look in the sites/all/modules/views/theme folder at the views-view-list.tpl.php, views-view-field.tpl.php and views-view-fields.tpl.php files.

Save a copy of these files in your own theme's 'templates' folder. Then you can edit the copies to strip code that makes <span> and <div> etc. You should also rename your version of these files according to the view's template suggestions so the changes only affect your view.

I used this for a view where I wanted to make 3 columns, so I wanted the classes li_1, li_2 and li_3 (in file views-view-list.tpl.php)

<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

global $cnt_ul;
global $cnt_li;
$cnt_ul++;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
?>
<ul class="<?php print $classNameUl ?>">
<?php
foreach ($rows as $id => $row): $cnt_li++;
$className = (($cnt_li % 3) == 0)? "li_". $cnt_li ." last" : "li_". $cnt_li;
?>
<li class="<?php print $className ?>"><?php print $row; ?></li>
<?php endforeach; ?>
</ul>
Source Link

Drupal likes to put spans and divs around every item. When you don't like that, you can override the PHP file that's causing this.

Look at: sites/all/modules/views/theme

views-view-list.tpl.php views-view-field.tpl.php views-view-fields.tpl.php

Look at those files, make changes if you want to, and save them in your own template folder. Here you can strip code that makes spans, divs...

You can also rename the filename in your template map, if you just want to do this for 1 view.

I used this for a view where I wanted to make 3 columns, so I wanted the classes li_1, li_2 and li_3 (file: views-view-list.tpl.php)

<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

global $cnt_ul;
global $cnt_li;
$cnt_ul++;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
?>
<ul class="<?php print $classNameUl ?>">
<?php
foreach ($rows as $id => $row): $cnt_li++;
$className = (($cnt_li % 3) == 0)? "li_". $cnt_li ." last" : "li_". $cnt_li;
?>
<li class="<?php print $className ?>"><?php print $row; ?></li>
<?php endforeach; ?>
</ul>