I am pretty sure this used to work fine, but I just updated views to the latest DEV release and now I am having some problems.

I have an Embed display that is is embedded at directory/page .

When I filter the view with the exposed filter (using a taxonomy filter), I am taken to the home page of my site with the tid argument appended to the domain name. In short, it looks like Views is looking for a path and since there isn't one, to the home page you go!

Comments

capellic’s picture

So, I added a Page display as a work around and I added a the same path as the node I am embedding the display in. Funny thing is, I didn't update my embed code to be page_1, but left it as embed_1. I then filtered the the list and the node reloaded with the view filtered appropriately. So, it would appear that it is picking up the path from the page display and then routing to the NODE - it's not taking it to the view. Interesting.

grndlvl’s picture

Status: Active » Closed (duplicate)
jstoller’s picture

Title: Filtering an exposed filter takes me to the home page » Filtering an exposed filter should stay on current page
Category: bug » feature
Status: Closed (duplicate) » Active

Reading the issue posted in #2, the Views maintainer clearly says that it is the responsibility of developers to account for the default behavior in their modules, so I'm reopening this as a feature request.

Unlike your standard Page display, an Embed Views Display is clearly intended to be embedded on other pages. It should automatically assume that any exposed filters are intended to post to the current page, rather than the home page, or some random Page display in the same view. I would like to see this handling built into the module.

For what its worth, the workaround I am currently using is the following hook_form_alter() function:

<?php
/**
* Implementation of hook_form_alter().
*/
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form['#id'] == 'views-exposed-form-MY-VIEW-embed-1'){
    $form['#action'] = '/' . drupal_get_path_alias($_GET['q']);
  }
}
?>

I'm sure there are better ways of doing this, but it seems to work so far. However, I'd much prefer to see this handled in Views when the display is built.

grndlvl’s picture

Status: Active » Needs review

Fix available in 6.x-1.x commit 48a6802, 18bef9f.

Once it has been reviewed by another or sits here for at least a week I will add it to a release.

grndlvl’s picture

Status: Needs review » Fixed

Available in the latest release 6.x-1.2

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

benkewell’s picture

Version: 6.x-1.1 » 6.x-1.2
Category: feature » bug
Status: Closed (fixed) » Needs review

Current fix in version 1.2 is written as:

/**
* Implementation of hook_form_FORM_ID_alter().
*/
function embed_views_form_views_exposed_form_alter(&$form, &$form_state) {
  // Change the action of the form for all embed views.
  if ($form_state['display']->display_plugin == 'embed') {
    $form['#action'] = '/' . drupal_get_path_alias($_GET['q']);
  }
}

which doesn't work if Drupal is installed inside a sub-directory under domain root, like http://www.example.com/drupal/
Below is a modified version of form alter function to fix the problem:

/**
* Implementation of hook_form_FORM_ID_alter().
*/
function embed_views_form_views_exposed_form_alter(&$form, &$form_state) {
  // Change the action of the form for all embed views.
  if ($form_state['display']->display_plugin == 'embed') {
    $menu = menu_get_item();
    $form['#action'] = url($menu['path']);
  }
}
grndlvl’s picture

Status: Needs review » Fixed
StatusFileSize
new551 bytes
new551 bytes

A similar fix to #7 has been applied to both 6.x & 7.x.

Use 6.x-1.3 or 7.x-1.1

Or apply the correct corresponding attached patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

chichilatte’s picture

Priority: Normal » Minor

I'm getting the same issue for Views 6.x-3.0rc2 (Drupal 6.2.2). Glad to report your fix worked for me :)

grndlvl’s picture

Do you mean the views module proper?

This is an additional views display that automatically adds this capability to all embed view display types.

Did you just implement your own hook_form_views_exposed_form_alter(). If so glad that worked for you and I will close this ticket.

Otherwise, could you verify that you are using the latest release of embed views display and that you are attempting to embed and embed display.

Thanks,

Jonathan