Hey Guys,
I'm trying to change the date filter for one of my views dynamically so I can output a set of nodes from a fixed time frame depending on the views argument. For example, if the argument date is 2-19-09, I would like the view to display all nodes created between 2-10-09 to 3-10-09. I wrote the script to calculate the min and max date for the view, however, when I try to set those parameters and display the view the date range limit is not applied.
I created a dummy filter under the views admin gui with "Node: Post date between 2000-01-01 and 2020-01-01" to encapsulate all nodes
Then I tried to edit that filter dynamically in a custom php block with
$view = views_get_view($view_name) or die('No view available.');
$display_id = "panel_pane_" . $display_id;
$view->set_display($display_id);
$view->display[$display_id]->display_options['filters']['created']['value']['min']=date("Y-m-d",$date_range['start_date']);
$view->display[$display_id]->display_options['filters']['created']['value']['max']=date("Y-m-d",$date_range['end_date']);
$view->is_cacheable = FALSE;
print $view->preview($display_id, array($term_id));
Where $date_range['start_date'] is the min post date of the node and $date_range['end_date'] is the max post date of the node.
Help would be greatly appreciated thanks.
Comments
Date range filter
I'm trying to do a similar function but haven't accomplished it. Did you ever figure it out? It would be of a great help.