I have a view set up with a block display. Its style is set to HTML list, which it does with no problem. But it doesn't seem to be applying the CSS class listed in the setup. What do I need to do to get this to apply?

enter image description here

Edited to add: Drupal 6, Views2

  • EmmyS - can you provide more information on how you can confirm that the class isn't being displayed correctly? Is it not showing up for you in firebug, view-source, etc? – schnippy Jan 27 '12 at 17:02
  • Sorry; yes. Tried view-source, Firebug, and Chrome's inspect element. Don't see the class being added anywhere. – EmmyS Jan 27 '12 at 17:38

I said IF its D7 bc I could not find what version. I was reading it on my phone. But here's your Drupal 6 answer:

But here's the template suggestions for D6: http://drupal.org/node/1089642

You can download devel module to get template suggestions as well.


Download this module to add css classes to specific blocks:


| improve this answer | |

I think you can try to create a custom css file in sites/all/themes/yourtheme/css/ and trace from page class, views class. I am sure this will work, but still this is just to test the root cause for the issue. If even this doesnt seems to work i would suggest you to disable and uninstall the views module and then enable it. At times enabling a module again has solved my issues.

| improve this answer | |

Don't know if this will work but it's what I've done on occasion:

Remove the css class name in your view. That should cause Drupal views to automatically add the class ".view-sessions-by-track" which should be easy to track down.

| improve this answer | |
  • Nope; didn't seem to work. – EmmyS Jan 27 '12 at 21:11

You can do theme overrides in D6 too. Just look up the specific syntax for the API & replace it w/ that. There really isn't a big diff between D6 & D7. It's just naming conventions, a few processes, & hooks.

Wait til D8 comes out in 12 months. No more php template. It's going to Twig.

| improve this answer | |

If its Drupal 7 you need to theme your blocks. You can override that by creating a block.tpl.php file & place it where your html.tpl.php file resides.

Next goto http://drupal.org/files/issues/Core_templates_and_suggestions.pdf to see what template suggestions you might need. You can also search drupal.org for more, bc your block.tpl.php file might be named block--%--.tpl.php < % denotes wildcard.

Next you will have to theme you block. You can control the HTML output with the $output variable, as well as classes and ID's. You have the option of generating classes and UD's statically or dynamically.

You could also do a theme preprocessing function (your_site_name HTML &vars function) in the template.php file.

Example for block.tpl.php

/* more code here, below outputs whatever you code here */

$output .= '' . $links['title'] . ''";

| improve this answer | |
  • My original post is very clearly tagged as version 6, and even states it in the post text. Why propose a solution that only works on 7? – EmmyS Nov 20 '12 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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