Howdy,

Is there any way to remove the DIVs that surround lists in Drupal 6? I see many of them in views-view-list.tpl.php, and I don't want to edit that file because it'll just get overwritten when I upgrade.

Thanks!
Adam

Comments

primalmedia’s picture

These are the ones I'm looking to remove, any input would be appreciated.:

<div class="view-content">
<div class="item-list">
<li class="views-row-1 views-row-odd views-row-first"> (I want to keep the LI, but remove the class)
<div class="views-field-title">
<span class="field-content">
merlinofchaos’s picture

Category: bug » support
Priority: Normal » Minor
Status: Active » Closed (won't fix)

You're using Drupal. I recommend you read the documentation on theming. Also, this is not a bug.

primalmedia’s picture

Status: Closed (won't fix) » Active

Thanks Merlin of Chaos! I understand this is by design. What I'm looking for is some information on how to theme away the unnecessary DIV's that Views needlessly adds to lists. Personally, I think it's a bug. I'd like to keep this support request active in case someone has better ideas on how to fix this Bug.

Other people are also looking for smart, clean code without the superfluous DIV's and classes: http://drupal.org/node/266737, and other people are bouncing ideas around for best ways to remove the DIV's from list views: http://drupal.org/node/157380. So why is this by design? And has anyone figured out a way to repair this bug in Drupal 6?

merlinofchaos’s picture

Status: Active » Closed (won't fix)

So you didn't actually read the documentation? There is documentation on how to theme Views, and if you are not interested in reading it, then why would anyone be interested in helping you? If the documentation is unclear, perhaps asking specific questions would get better results.

LiquidWeb’s picture

First of all this is not a bug but feature (I like using this sentence :) ) and please click "Theme information" link on View configuration page that will make everything clear.

catch’s picture

primalmedia’s picture

Thank you rakisisesindekibalik for telling me about the Theme Information. It was useful to find out about rescanning the template files.

I still do not understand why all the DIV classes and LI classes need to be there. Does anyone have a good explanation for this? I've read something where Merlin says he can justify them all, but I wasn't able to find his reasons. Why not just clean code?

To get rid of the LI classes and the

, I copied the views-view-list.tpl.php from the Views Theme folder to my theme folder and removes the class tag. For the other two DIV's I edited the views-view.tpl.php from the Theme Information.

Thanks again for your help.
Adam

merlinofchaos’s picture

Search closed issues. I've explained this a few times, and I'm tired of explaining it.

The divs and classes are there because they are necessary to do some things. Just because they aren't things you want to do is irrelevant. You are not going to get a detailed breakdown of every class and every div, my time is more valuable than that.

Please stop complaining about this issue. This is not changing. If you don't like it, you've got two choices: Theme it, or go use another piece of software. EOF.

Paul Lomax’s picture

What we do:

- Create a theme in your sites/all/themes folder, call it 'reset' or similar.
- Add views-view.tpl.php & views-view-unformatted.tpl.php to it. (Plus any others you are likely to use, copy them from the views module folder)
- Remove all div's from said files.
- You can also add any CSS resets you use a lot in here, or common theme functions. Things that Drupal does by default that you are never likely to use.

Include this theme in your main site theme by putting:

base theme = "reset"

In your .info file.

Job done, you will never see those div's again.

The big problem is there is a large divide in Drupal between people who build sites using entirely contributed themes, i.e. They never touch any code, and more advanced 'themers'.

The div's are there for the former, some stuff you can do with views will break without them and if you don't know how HTML works it would be impossible to figure out.