0

I have a custom views-view-list.tpl.php template that uses

foreach ($view->style_plugin->rendered_fields as $delta => $item)

to manipulate the fields at this template level rather than using

foreach ($rows as $id => $row)

and relying on views-view-fields.tpl.php to render the HTML.

However, when using grouping in a view, the views-view-list.tpl.php is called once for each grouping, but the first method renders all items, rather than just the ones in the current grouping.

How can I tell from views-view-list.tpl.php which items belong to the current grouping?

0

Turns out the $rows object has indices that don't go from 0, counting up by 1. It keeps only indices of the items in the current group. That makes this code work:

<?php foreach ($view->style_plugin->rendered_fields as $delta => $item): ?>
    <?php if(isset($rows[$delta])) : ?>
         ... print out whatever necessary ...
    <?php endif; ?>
<?php endforeach; ?>

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.