Здравствуйте. Пытаюсь вывести с помощью views API ноду. Делаю так:
<?php$viewName = "product_display";
$view = views_get_view($viewName);
$view->set_display('default');
$view->set_arguments($node->nid);
$view->execute();
$viewArray = $view->result;
echo"<pre>"; print_r ($viewArray); echo"</pre>";?>
Получаю пустоту. При этом views_embed_view('product_display', 'default', $node->nid); все прекрасно выводит. Но обладает недостатками в виде отсутствия заголовка и, как я понял пока гуглил, разными другими подводными камнями. Из-за чего ничего не выводится?
Комментарии
в set_arguments надо массив передавать:
array($node->nid)
и еще кое-что... пример:
<?php
// Set the specific line items for this order.
// Override the view url, if an override was provided.
// Prepare and execute the View query.
// Return the rendered View.
/**
* Renders a View for display in some other element.
*
* @param $view_key
* The ID of the View to embed.
* @param $display_id
* The ID of the display of the View that will actually be rendered.
* @param $arguments
* An array of arguments to pass to the View.
* @param $override_url
* A url that overrides the url of the current view.
*
* @return
* The rendered output of the chosen View display.
*/
function commerce_embed_view($view_id, $display_id, $arguments, $override_url = '') {
// Load the cart line item View.
$view = views_get_view($view_id);
$view->set_display($display_id);
$view->set_arguments($arguments);
if (!empty($override_url)) {
$view->override_url = $override_url;
}
$view->pre_execute();
$view->execute();
return $view->render();
}
?>
Спасибо, это помогло найти правильное решение )