Setting exposed filters when using views_get_view
jim0203 - July 5, 2009 - 15:15
| Project: | Views |
| Version: | 6.x-2.6 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I've got a view which uses a couple of exposed filters. I want to call the view using $view = views_get_view - but how do I set the exposed filters using this method?

#1
This one is quite easy. After the views_get_view and before anything else:
<?php$view->set_exposed_input(array('identifer' => 'value', /* ... */));
?>
#2
Thanks Earl, that works great.
Is there anything similar that works with views_embed_view()? In other words, how do I set an exposed filter for an embedded view?
#3
views_embed_view is just a wrapper, easy to use helper functions, but if you want to do more, you cannot use it.
See the code of views_embed_view, there you have the full $view object to do what you want to do with it.
I think if it works fine, this could be closed
#4
Thanks dereine. I worked out a way to do what I wanted to do: I changed the view to accept arguments in place of the data entered into the exposed fields, and it worked great:
<?phpviews_embed_view('view_name', 'default', 'arg1+arg2+arg3')
?>