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

joachim’s picture

Oops.
I mean the style template -- eg, views-view-unformatted.tpl.php

jmcintyre’s picture

I 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?

jmcintyre’s picture

Upon 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:

<?php foreach ($rows as $id => $row): ?>
  <?php print $row; ?>
<?php endforeach; ?>

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?

dawehner’s picture

What 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

Letharion’s picture

Assigned: Unassigned » dawehner
Category: bug » feature

@dereine
So is this a feature request then?

dawehner’s picture

Oh, yes it's definitive a missing feature.

Letharion’s picture

Assigned: dawehner » Unassigned
Category: feature » task
alex.skrypnyk’s picture

subscribing

MustangGB’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)