Sorry if this is a known bug but I searched and couldn't find a related issue.
I have a view which has a "Feed" display (xml), and a "Views Pane" display.
On the "Feed" display the supplied path/URL for the display is "feed/xml".
The "Views Pane" display has a contextual filter for "Taxonomy term" and also a pager that has "Expose the Items Per Page" set to on.
Now when the "Views Pane" is included in a Panel, the Contextual Filter value (term id) is supplied from the Panel context (Node being viewed: term field on node). So now when you view the panel page and try to change the Items Per Page exposed form, it tries to submit the form to the "Feed" display's path which is "feed/xml" and that's wrong. Ideally the #action
of the exposed form should be submitting to the current URL.
So I went back to the view and edited the "Views Pane" display, opened to "Allowed settings" and set "Path override" to on. And then went to the Panel config, and I put %node:url
as the "Path override".
All well and good so far, but now when I view the Panel page and look at the exposed form's #action
its the correct url BUT with added extra parameter which is the Contextual Filter's taxonomy term id. For example: if my current page is path/to/my/page
then the #action
of the form is path/to/my/page/115
where 115 is the ID of the taxonomy term currently supplied to the views pane through the panel context. So submitting the form produces a 404 in this case.
What I've tried so far is:
- Preprocessing the panel pane (theme_preproces_panel_pane) which didn't help a great deal as the view was already rendered as HTML in the content
key of the $variables
array. At this point I realized preprocessing theme functions won't work.
- So I moved on to Views hooks and tried hook_views_pre_render
. dpm
-ing the $view
from this hook, I can see that $view->override_path
(string) is the correct URL (without the extra term id), but the exposed form was also already rendered here in $view->exposed_widgets
(string, rendered HTML) with the wrong URL (with extra term id).
So before I go through all Views hooks, and maybe not even come up with a solution, I wanted to ask this question, if anyone knows when exactly this exposed form is being rendered OR how I can stop the Taxonomy Term ID from being attached to %node:url
token (Perhaps a simple configuration that I've missed or.. ?).
Edit
So I went through all the Views hooks. Also implemented a hook_form_views_exposed_form_alter
. From the order the dpm
's are being outputted, it looks like the order of execution is:
hook_views_pre_build
- Exposed form gets built (dpm of hook_form_views_exposed_form_alter)
hook_views_post_build
hook_views_pre_execute
hook_views_post_execute
In hook_views_pre_build
the path_override
is correct. Form is not rendered yet.
In hook_views_exposed_form_alter
the form render array is built, and $form['#action']
shows the wrong path with the extra term id.
So I need to somehow get in between these 2 functions and supply the correct #action...
#action
in the form alter, why don't you just correct it there?view
is available in$form_state['view']
... didn't know that...