传递UID作为参数正常工作与此代码:Drupal的6次2:设置日期参数
$bouts = views_get_view_result('Results', 'page_1', array($user->uid));
在views_get_view_result重点线,设置参数为:
$view->set_arguments($args);
但是关于通过什么日期范围?
另外,如果在视图中指定了某种过滤器,是否有一种方法可以对它进行参数化修改?
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));
}
}
AFAIK views模块中没有'views_get_view_result()'函数 - 你自己声明了吗?如果是这样,你应该添加它的定义以允许答案。 – 2009-08-23 17:43:28
你已经创建了如此多的drupal问题。你应该把所有的东西合而为一。 – 2009-08-29 03:45:20