I have a view that with row-style set to “fields”. Rather than theme the individual rows the normal way — i.e. with style, row, and field templates — I would like to extract certain information from each row, bundle up the extracted information as a json object, and then pass the json object to a script. The script will then render all the row-data.
I created a custom template, views-view-unformatted–myview.tpl.php with the following code:
<?php
$rowdata = array()
foreach ($rows as $key => $row) {
dsm ("row $key: "); dsm ($row);
$rowdata[$key] = dostuff($row);
}
?>
Unfortunately, I discovered that $row is no longer an object (which is what I need). It has already been rendered as an html string.
How do I tell views “please do not render the individual rows. I need access to the row data”
Thanks
I solved my problem by creating a views plugin. The approach is similar to what is described here http://groups.drupal.org/node/10129, in the section “Writing Views 2 Style and Row Plugins”. I created a style plugin (but not a row plugin), and in the style definition I set ‘uses row plugin’ to false. I was then able to access the row data from within my style template. This allowed me to bundle up all my rows as json objects.