I don't know why, but Views doesn't add "human-readable" CSS class names (like e.g. the machine name of the view) to the blocks it creates (it only adds its classes to the generated "content" part when adding classes to the "CSS class" part in the view editor (see the screenshots below!)).
It only adds the usual block block-views
, and possibly contextual-links-region
CSS classes to the block(s), and generates a unique id (not class) like this: block-views-3d8f7966168beeec655c8ead69336789
(because its delta is this generated hash code).
It doesn't make sense to write CSS rules for these classes and ids (like .block-views-3d8f7966168beeec655c8ead69336789 { /* ... */ }
), because these classes/ids might change when altering the Views block.
How can I add some custom CSS classes in an implementation of hook_block_view_alter()
, if I cannot even identify these blocks because of their generated hash delta?
I do not want to use Block Class, because I feel it's like an overkill for just adding some classes to one or two Views-generated blocks (BTW I checked the module, and I feel SELECT css_class, module, delta FROM {block_class}
query in block_class_preprocess_block()
like an overkill, because it checks ALL the added classes, even if the block is hidden...).
So I would like to solve it from my own module.
EDIT
An example: