Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-3.0
Component:
Views Data
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Feb 2012 at 20:53 UTC
Updated:
23 Feb 2012 at 21:40 UTC
I have a page view that has a couple filters which are not exposed to the user. Users are not to have control over them, but they should able to change at render time. I did something like this a year and a half ago but completely forget the process.
Is it possible to execute a new filter at the preprocess stage? I am doing the following below and it seems to be having no effect.
E.g
function MYTHEME_preprocess_views_view(&$vars) {
if ($vars['name'] == 'MyDisplay') {
$display_id = $vars['display_id'];
switch ($display_id) {
case 'page_2':
$view = $vars['view'];
$filter = $view->get_item($display_id,'filter','field_story_news_type_value_many_to_one');
$filter['value']['value'] = 2;
$view->set_item($display_id,'filter','field_story_news_type_value_many_to_one',$filter);
$view->execute_display();
$vars['view'] = $view;
break;
}
}
}
Comments
Comment #1
merlinofchaos commentedAt render time the filters are already processed, the query created and executed and results have been rendered.
You can't go back in time.
Comment #2
skalfyfan commentedMerlin,
Thanks for quick response. Can we modify arguments before rendering then and moving it into a module? I have tried converting my filters to arguments instead and the hooked into pre_render with no results? Any suggestions?
Thanks
Comment #3
skalfyfan commentedResolved.
Same code as above but using the following hook instead resolves the issue.
Comment #4
skalfyfan commentedComment #5.0
(not verified) commentedfixed code