傳遞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