Exposed form in block change the action url | drupal 6 | views | hook_form_alter

I created an exposed filter in views that shows up in a block.

First I went to:

admin/build/views/edit/archive_magazine

and set the following

 

Exposed form
Exposed form in block: Yes
Exposed form style: Basic
under :
Exposed form
I set :
Exposed form in block: Yes
Exposed form style: Basic
Next I went to :
admin/build/block/
and did a text search with my browser for -default
in my case I had the block named 'view_name-default
Then I enabled the block to show up on the same page as my view
But when I change the parameters of the form and hit 'apply' it sends me to the homepage. 
So here is where you have to modify the form to make sure it is going to the right place
I put a function in one of my custom modules.

function category_content_type_form_alter(&$form, $form_state, $form_id) {
   if($form_id == 'views_exposed_form') {
          $form['q']['#value'] = 'taxonomy/term/19';
                //if you want to change the root value you can do it with action
 //$form['#action'] = '/';
   }
}
For those of you that are looking for this because your view is not responding to the exposed block when you hit apply. The reason it may not be responding is because the filter exposed as a block cannot talk to a view exposed as a block. If you want your exposed filter in a block to talk to the view then you have to have the view set to "Page" not "Block" and then use the block manager to embed the exposed form as a block into the "Page." 


 

Trackback(0)
Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security image
Write the displayed characters


busy