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?

Comments

merlinofchaos’s picture

This one is quite easy. After the views_get_view and before anything else:

  $view->set_exposed_input(array('identifer' => 'value', /* ... */));
jim0203’s picture

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?

dawehner’s picture

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

jim0203’s picture

Status: Active » Closed (fixed)

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:

views_embed_view('view_name', 'default', 'arg1+arg2+arg3')