传递UID作为参数正常工作与此代码:
$bouts = views_get_view_result('Results', 'page_1', array($user->uid));
在views_get_view_result重点线,设置参数为:
$view->set_arguments($args);
但有关传递日期范围是什么?
另外,如果事情被指定为在视图上的过滤器,是有办法prorammatically改变呢?
views_get_view_result:
/**
* Investigate the result of a view.
* from Drupal.org.
*
* @param string $viewname
* The name of the view to retrieve the data from.
* @param string $display_id
* The display id. On the edit page for the view in question, you'll find
* a list of displays at the left side of the control area. "Defaults"
* will be at the top of that list. Hover your cursor over the name of the
* display you want to use. A URL will appear in the status bar of your
* browser. This is usually at the bottom of the window, in the chrome.
* Everything after #views-tab- is the display ID, e.g. page_1.
* @param array $args
* Array of arguments. (no keys, just args)
* @return
* array
* An array containing an object for each view item.
* string
* If the view is not found a message is returned.
*/
function views_get_view_result($viewname, $display_id = NULL, $args = NULL) {
$view = views_get_view($viewname);
if (is_object($view)) {
if (is_array($args)) {
$view->set_arguments($args);
}
if (is_string($display_id)) {
$view->set_display($display_id);
}
else {
$view->init_display();
}
$view->pre_execute();
$view->execute();
/* print "<pre> $viewname: $display_id";
print_r(get_class_methods($view)); */
return $view->result;
}
else {
return t('View %viewname not found.', array('%viewname' => $viewname));
}
}