I have a view which I'm calling programmatically using views_get_view();

$display_id = 'default';

$view = views_get_view('timemachine_doc');
$view->set_display($display_id);

$filter = $view->get_item($display_id, 'filter', 'field_doc_docid_value');
$filter['value']['value'] = $docid;
var_dump($filter['value']['value']);
$view->set_item($display_id, 'filter', 'field_doc_docid_value', $filter);

$filter = $view->get_item($display_id, 'filter', 'field_tm_from_value');
$filter['value']['value'] = $date;
$view->set_item($display_id, 'filter', 'field_tm_from_value', $filter);

$view->pre_execute();
$view->execute($display_id);
var_dump($view->build_info);
$n = $view->result[0];

On each run through $filter['value']['value'] is populated.
On the second run through $view->build_infos query_args is blank but it isn't on the first.

I'm not entirely sure what's going on so any help would be greatly appreciated.

Comments

budda’s picture

Can you paste an export of your view configuration in full to help anyone get an idea of what filters, arguments, fields are defined.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Do i see it right that you have a foreach/for loop around this pice of code?

If yes you should probably remove $view->built or call $view->destroy() after each execution.

mikebell_’s picture

Hi,

I don't have a $view->built in the code. I'm not sure what you mean here.

I added the $view->destroy but still no luck.

mikebell_’s picture

Status: Postponed (maintainer needs more info) » Active

I've spent some more time with this and traced it down to where $view->build is called within $view->execute.

I'm not quite sure how get_where_args() works. If I look at what is in $this->query I see no actual value, or at least nothing I would expect. I'm pretty stuck on this.

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)