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
Comment #1
buddaCan you paste an export of your view configuration in full to help anyone get an idea of what filters, arguments, fields are defined.
Comment #2
dawehnerDo 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.
Comment #3
mikebell_ commentedHi,
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.
Comment #4
mikebell_ commentedI'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.
Comment #5
mustanggb commented