Is it possible for me to have views output unique CSS classes for each views-grouping-content div? For example, I have a view using Unformatted List style, with three grouping fields set in the style plugin. At the moment all I get is:

<div class="view-grouping"><div class="view-grouping-header">Grouping Field #1</div><div class="view-grouping-content"><div class="view-grouping"><div class="view-grouping-header">Grouping Field #2</div><div class="view-grouping-content"> <h3>Grouping Field #3</h3>

This does not allow me to theme the nested grouping fields. I want to visually display these nested groups as "containers", which I could easily do with CSS if I could just define a unique CSS class for each grouping field, so that the output would be:

<div class="view-grouping myclass1"><div class="view-grouping-header">Grouping Field #1</div><div class="view-grouping-content"><div class="view-grouping myclass2"><div class="view-grouping-header">Grouping Field #2</div><div class="view-grouping-content"> <h3>Grouping Field #3</h3>

And so on. Even the "class for grouping level" raised in http://drupal.org/node/1488744 would help, if it were applied to the view-grouping-content or view-grouping divs, as well as the view-grouping-header.

This small feature would open up a LOT of possibilities for using grouping to visually represent nesting/containers/hierarchies.

Thanks!

Comments

stephen.punwasi’s picture

Second this request!

rdentry’s picture

Has anyone figured this one out?

rdentry’s picture

Basically I am trying to add a separate color to each .view-grouping div, so I would need unique identifiers. I was hoping that I could do something similar to how the views-row-1 and so on is added, but since that group div is added via template (views-view-grouping.tpl.php), I'm not sure how to add this. Any help would be much appreciated.

lunk rat’s picture

@rdentry: I was able to get something cooking, check out #7 in this thread: http://drupal.org/node/1488744

And look at the posts after that.

Lunk

rdentry’s picture

@lunk_rat: Thanks a lot for the quick response. I did try that, but I still kept getting '0' for each one. Any clue why?

Update:
Turns out that your fix does work and is very helpful! I think I was just asking for something a little different. The levels of grouping work great, but what I am trying to achieve is adding a unique identifier for the first divs like this:

div class="view-grouping group-level-0 group-1"
div class="view-grouping group-level-0 group-2"
div class="view-grouping group-level-0 group-3"
div class="view-grouping group-level-0 group-4"

Since for me it is only for aesthetic reasons, I've added this via jquery, but would be nice if I could integrate it in the .tpl file instead of javascript.

mattia.cristallo’s picture

same problem, have u solved?

lunk rat’s picture