How can I render a result row using the Views API I'm trying to render the rows in a view manually using the Views API. The style plugin is the "Unformatted" plugin. This is my code:

&lt;?php
$view = views_get_view('nearme');
$view-&gt;execute('default');
$view-&gt;preview();

$renderer = $view-&gt;style_plugin-&gt;row_plugin;
foreach ($view-&gt;result as $row) {
  echo $renderer-&gt;render($row);
}
?&gt;


This code almost works - it renders essentially a blank row. My "Global: custom text" field is rendered, as are some generic labels and field HTML, but the actual values from $view->result are not interpolated.

What am I doing wrong?
The tokens in views requires $view->row_index to be set to be able to get the right rendered fields.

$view = views_get_view('nearme');
$view-&gt;execute('default');
$view-&gt;preview();

$renderer = $view-&gt;style_plugin-&gt;row_plugin;
foreach ($view-&gt;result as $index =&gt; $row) {
  $view-&gt;row_index = $index;
  echo $renderer-&gt;render($row);
}