When I embed a view with exposed filters in a MENU_LOCAL_TASK page, then click on "Apply" to run the exposed filters, the URL does not return to the MENU_LOCAL_TASK page.
Here is the menu setting (in hook_menu):
$items['views_mail/view/%'] = array(
'title' => t('Select email list'),
'page callback' => 'views_mail_view_view',
'access callback' => 'user_access',
'access arguments' => array('send views mail'),
'weight' => 11,
'type' => MENU_LOCAL_TASK,
);
Here is the page itself:
/**
* Display view and use exposed filters to select the email list you wish
* wish to send to.
*/
function views_mail_view_view() {
$viewname = arg(2);
// Create the embedded view
$view = views_embed_view($viewname, 'default');
return $view;
}
This view has exposed filters. If you select a filter and click "Apply", then you are taken away from the page you are on. I looked at the source code, and the form action = "/". This would account for why the resulting url is something like:
http://www.mysite.com/?rid=7. The source code should say form action = "ThePageThatViewIsOn" (in this case, "views_mail/view/viewname").
In order to debug, I created my own custom views_embed_view function and after the $view is loaded, I added:
$view->url = $_GET['q'];
$view->path = $_GET['q'];
(see similar issue in 5.x: http://drupal.org/node/135214) to no effect.
So, I'm assuming that if there is not a way to have the exposed filter from an embedded view come back to the same page from which it's called, then that's a bug. If not, how do I fix it?
Thanks!
Comments
Comment #1
merlinofchaos commentedSee the function
view::get_path()wherein you will see that there is aview::override_pathvariable you can set to force a path.Otherwise it gets the path from the display handler; default displays have no path so you just end up with '' which is also known as '/'.
Comment #2
somebodysysop commentedAbsolutely works. And, I see it isn't a bug but a feature.
For those who are as new to this as I am, I only needed to add this to the view to resolve the issue:
Thank you so much for the quick reply.
Comment #4
Mordine commentedis the $view::override_path variable view specific and where would I put it?