How to assign a rendered view result to a variable without displaying it on the screen? I am working  on a module to collect the results from several views, to be concatenated and then displayed. The views are returning JSON data using the views_datasource module.
To do this, I tried to set a variable to be the output of a view like so:
$my_view = views_get_view('drupalgap_content');
$my_view-&gt;set_display('getlatestdigest');
$output = $my_view-&gt;render();

Then I could concatenate the $output to another views output etc.
The problem lies in the fact that as soon as I call $view-&gt;render() it renders the view results to the screen (I presume with a print() function) somewhere deep in the views core module.
After a ton of googling, I found that in the past, $view-&gt;render() used to return a value, and this method was correct.  However, somewhere along the line, they changed it so $view-&gt;render() it renders the view results to the screen, making it impossible to concatenate the view output to another view output.
Other options I've looked into that don’t work:

$view_result = views_get_view_result('drupalgap_content','getlatestdigest');
This gets the view result, but it does not get the rendered JSON output that I need from the views_datasource module.  So, it’s no good.

$view-execute(),$view-&gt;preview('getlatestdigest'); $view-&gt;execute_display('getlatestdigest', array());
All of these three functions do the same thing as view-&gt;render(), i.e. they output the nicely formatted results I want to the screen instead of assigning them to a variable.

views_embed_view('drupalgap_content',  ‘getlatestdigest');
does the same thing as view-&gt;render(), i.e. outputs the nicely formatted results I want to the screen instead of assigning them to a variable.


I should also mention that I am calling this module’s function using an AJAX call from a mobile app to the menu_hook for this page_callback.  So I can not have it outputting anything to the “screen” until it is ready since AJAX will return the data to the client as soon as the output to the screen is called.
This turned out to be an issue with the views_datasource module, not the views module.  Solved by enabling "Views API mode" in the View settings.