recentpopularlog in

therobyouknow : dropbucket   1

Render view's exposed form anywhere in a theme/module | Drupal snippets
/**
 * Returns rendered exposed form for a given view.
 * $view_name
 * - A string with a view name,
 * $display_id
 * - A string with a name of view display,
 * @return
 * Rendered exposed form.
 */
function MY_MODULE_render_exposed_form($view_name, $display_id = 'page') {
$view = views_get_view($view_name);
$view->set_display($display_id);
$view->init_handlers();
$form_state = array(
'view' => $view,
'display' => $view->display_handler->display,
'exposed_form_plugin' => $view->display_handler->get_plugin('exposed_form'),
'method' => 'get',
'rerender' => TRUE,
'no_redirect' => TRUE,
);
$form = drupal_build_form('views_exposed_form', $form_state);
return drupal_render($form);
}
Render  views  exposed  form  anywhere  theme  module  obtain  computing  web  dev  cms  howto  dropbucket  code  snippet  drupal 
september 2013 by therobyouknow

Copy this bookmark:





to read