This view is a black book directory that will have a long list of links to static pages. The problem I am having is the output isn't coming out as an unordered list like I have set. Each link is set in a span and a row. Is it possible to output a simple ul with an id on it. I am having trouble matching my design. Thanks

4 Answers 4


Set the view style to "HTML List," then the style option to "Unordered list."


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)

// $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;

$classNameUl = (($cnt_ul % 3) == 0)? "ul_". $cnt_ul ." last" : "ul_". $cnt_ul;
<ul class="<?php print $classNameUl ?>">
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; ?>
  • Could I modify this to add an li for each letter of the alphabet with a special id and class to the list? I am trying to make an iphone-like contact list/directory of links all in alphabetical order Dec 30, 2011 at 23:12
  • I do have each of these files tailored specifically to the view I am working with. I am failing to understand your code as I hardly know any PHP. I am sure it is possible to programmaticly write some code to add a line like this: <li id="A" class="highlight">A</li> for each letter of the alphabet. Can you help me figure out what I should do make this happen. Jan 1, 2012 at 0:46

You should also take a look at the Semantic Views module, which allows you to change the HTML output of the view from within the Views UI and largely avoid getting involved in template files.


sure you can style the lists.You probably have just one field in views that is Tittle so just add this to style.css in theme css folder

.view-view-name .views-field-title 


Where view-name is a machine name of your View(you can find that in views settings )

  • But i'm still getting the links wrapped in span tags. I need <ul id="..."><li>... Dec 29, 2011 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.