Drupal 6 Views 2: Установка аргументов даты
Передача uid в качестве аргумента прекрасно работает с этим кодом:
$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 "
$viewname: $display_id"; print_r(get_class_methods($view)); */ return $view->result; } else { return t('View %viewname not found.', array('%viewname' => $viewname)); } }