Sign up ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I made a View, and I exposed the filters in a block; then, in the block's administrative screen, I set this block not to appear in the view that belong. In the actual view I don't want to show this block. Instead, I want the filters to appear in the content as they normally would if I didn't expose them in a block.

If that makes any difference, I am using Drupal 7.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

My understanding is that your view has exposed filters and that Exposed form in block is set to Yes.

To put the exposed form where it would appear if it weren't in block, you should be able to place the exposed form block into your Content region, above the view itself.

To have the exposed form displayed in both the view and a separate block, leave the form in the view and create a PHP block with the following body:

  if ($block = module_invoke('views', 'block', 'view', '-exp-YOUR_VIEW-YOUR_DISPLAY') ) {
    print $block['content'] ;
share|improve this answer

The accepted answer did not work with Drupal 7 for me. I followed with success. Code below:

/** implements hook_block_info() **/
function test_block_info(){
  $blocks = array();
  $blocks['custom_exposed_filter_form'] = array(
    'info' => t('Exposed filter form'),
    'cache' => DRUPAL_NO_CACHE,
  return $blocks;

/** implements hook_block_view() **/
function test_block_view($delta = ''){
  $block = array();
    case 'custom_exposed_filter_form':
      $block['subject'] = t('Exposed filter form');
      $block['content'] = _test_get_exposed_filter_form();   
  return $block;

/** Function to get the Exposed filter form **/
function _test_get_exposed_filter_form(){
  // Get a view from the database or from default views . "test" is the view name.
  $view = views_get_view('test');
  // Set the display as current.
  // Acquire and attach all of the handlers to the view.
  $exposed_form = $view->display_handler->get_plugin('exposed_form');
  return $exposed_form->render_exposed_form();
share|improve this answer
$block = block_load('views', '-exp-VIEW_NAME-VIEW_DISPLAY');
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block)))); 
share|improve this answer
Can you provide a little summary of why/how this is different that the accepted answer? – MPD Feb 13 '13 at 23:30
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – Nikhil M Feb 14 '13 at 3:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.