Here is alternative way of merging results from two impossible views by using hook_views_post_render
:
/**
* Implements hook_views_post_render().
*/
function foo_views_post_render(&$view, &$output, &$cache) {
if ($view->name == 'my_view_1') {
// API: http://api.drupal.org/api/views/includes!view.inc/class/view/7
$view2 = views_get_view('my_view_2');
$view2->preview('page');
if (empty($view2->result)) {
return; // Return on empty results.
}
$dom = new DOMdocument();
$dom->loadHTML($output); // Load HTML from a string into DOM object.
foreach ($view2->result as $item) {
// Create field values.
$row1 = clone $row2 = clone $row3 = clone $row4 = clone $row5 = $dom->createDocumentFragment();
// TODO: Here, get the values assigned from $item ($view2->result).
$row2_title = 'same value from view2';
$url = 'some/url';
$row1->appendXML('<div>foo</div>');
$row2->appendXML(l($row2_title, $url)); // Link example.
$row3->appendXML('<div>foo</div>');
$row4->appendXML('<div>foo</div>');
$row5->appendXML('<div>foo</div>');
// Create columns and append content.
$td1 = $dom->createElement('td'); // row1
$td1->appendChild($row1);
$td2 = $dom->createElement('td'); // row2
$td2->appendChild($row2);
$td3 = $dom->createElement('td'); // row3
$td3->appendChild($row3);
$td4 = $dom->createElement('td'); // row4
$td4->appendChild($row4);
$td5 = $dom->createElement('td'); // row5
$td5->appendChild($row5);
// Create row and append columns.
$tr = $dom->createElement('tr');
$tr->appendChild($td1)->setAttribute('class', 'views-field views-field-row1');
$tr->appendChild($td2)->setAttribute('class', 'views-field views-field-row2');
$tr->appendChild($td3)->setAttribute('class', 'views-field views-field-row3');
$tr->appendChild($td4)->setAttribute('class', 'views-field views-field-row4');
$tr->appendChild($td5)->setAttribute('class', 'views-field views-field-row5');
// Apply changes to table and document.
$table = $dom->getElementsByTagName('table')->item(0)->getElementsByTagName('tbody')->item(0);
$table->appendChild($tr);
}
$output = $dom->saveHTML();
}
}
This solution is for table display only and it's adding new items of view2 into view1 results by parsing directly html output.
It has advantage of merging different type of views which doesn't share the same data, not using SQL or proper node objects or using different hooks (e.g. Search API, or YQL View).