Also, here is our Views Loop, where the following codes would equate to their corresponding variables in the above, pure php-based loop:
[wpv-post-id] = 'id'
[wpv-post-url] = 'title'
[wpv-post-title output="sanitize"] = 'url'
[types field="comm-calendar-event-type" output="raw"][/types]
[types field="comm-calendar-event-start" output="raw"][/types] = 'start'
[types field="comm-calendar-event-end" output="raw"][/types] = 'end'
[wpv-layout-start]
[wpv-items-found]<!-- wpv-loop-start --><wpv-loop>{[wpv-post-id output="raw"],[wpv-post-url output="raw"],[wpv-post-title output="sanitize"],[types field="comm-calendar-event-type" output="raw"][/types],[types field="comm-calendar-event-start" output="raw"][/types]000,[types field="comm-calendar-event-end" output="raw"][/types]000},</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
And this is the 'basic' php file in our theme for which we would want to json_encode:
<?php
include '../../../wp-load.php';
$args = array(
'title' => 'Calendar View',
);
$calendar_loop = array(render_view( $args ));
echo json_encode(array('success' => 1, 'result' => $calendar_loop));
?>
So far this is outputting:
{"success":1,"result":["\n\n\n\n\t\n\t9,http:\/\/localhost\/CALENDAR\/comm-calendar-event\/test-event-2\/,Test Event 2,event-info,1438819200000,1439510400000,8,http:\/\/localhost\/CALENDAR\/comm-calendar-event\/test-event-1\/,Test Event 1,event-warning,1438646400000,1438819200000,\n\t\n\t\n\n"]}
I'm just not sure why 1) the '\n\n\n\n\t\n\t' are appearing and 2) why I can't get the '{ }' to wrap around each loop item. I guess my question is now: how do I make an array out of render_view( $args )