Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a view is grouped, views-view.tpl.php is used for each grouped set, with the title used to output the grouping field.
As far as I can tell, there is no raw data about this field available to the template.
In theory you could go into $view->result and grab it there, but there's no way to tell which row(s) are currently being rendered, as the IDs in the $rows array are reset.
Comments
Comment #1
joachim CreditAttribution: joachim commentedOops.
I mean the style template -- eg, views-view-unformatted.tpl.php
Comment #2
jmcintyre CreditAttribution: jmcintyre commentedI too would really like to know how to do this. I don't even know if $view->result would get data from fields through relationships in the row's query.
Is there a reference anywhere to the Views-related variables available in views-view.unformatted.tpl.php? The code refers explicitly to $title, $classes, and $rows; and $view is assumed - perhaps there are others?
Comment #3
jmcintyre CreditAttribution: jmcintyre commentedUpon further investigation... I found that $view->style_plugin->rendered_fields contains all the data, including data from related nodes, for the query.
However, as the OP said, it's not clear how to match these up with the result rows if a grouping field is used for the view.
To clarify, when views-view.unformatted.tpl.php is used to display the first group of results, $id is in sync with the index of $view->style_plugin->rendered_fields:
On subsequent groups, however, $id restarts at 0. Perhaps there's a way to inject the index used to generate each element of $rows into another array variable available to the style template?
Comment #4
dawehnerWhat about having a theme_views_view_group?
This would have a) the title and the "subview" availible, by default just print the "subview" because the title is handled there
Comment #5
Letharion CreditAttribution: Letharion commented@dereine
So is this a feature request then?
Comment #6
dawehnerOh, yes it's definitive a missing feature.
Comment #7
Letharion CreditAttribution: Letharion commentedComment #8
alex.skrypnyksubscribing
Comment #9
MustangGB CreditAttribution: MustangGB commented