Hi!

I have some pretty unexpected behaviour going on.

What happens is, after executing an action, any argument in the path is appended to the URL. For example, if I have a view at node/12/widgets, and I submit it, the path goes to node/12/widgets/12. For some views, it is appended a few times, i.e. node/12/widgets/12/12/12 (after one submit).

Why does this happen? I'm not sure. The view is in a panel, and the panel takes an argument of %node. I believe it's the combination of views and panels which messes it up.

View attached.

CommentFileSizeAuthor
export.txt17.64 KBnagiek

Comments

bojanz’s picture

Status: Active » Postponed (maintainer needs more info)
nagiek’s picture

I'm already using the Use Panels Path option, but I haven't tried overriding the path directly.

Will let you know.

nagiek’s picture

Status: Postponed (maintainer needs more info) » Active

I tried using the Override Paths option, and it did have an effect, but it didn't solve the problem completely.

Observations:

  • The argument will still be appended to the URL, but it will only happen once. So I will never get node/112/widgets/112/112 in one submit, only node/112/widgets/112.
  • And if I resubmit the view after that, there will be no further appends. i.e. I will stay on node/112/widgets/112.
  • If I navigate to node/112/widgets/112 directly and submit the view, nothing will be appended.
  • The behaviour is consistent no matter how many views I have on the page: always one extra argument on the URL appended.

Thanks

nagiek’s picture

Did some more research, and noticed the #action property in the form is not built correctly: it has the argument appended, thus when you submit it goes to the url.

That should fix it.

mstrelan’s picture

g089h515r806’s picture

I have the same issue,
companycenter/22/events,
companycenter/22/events/22
companycenter/22/events/22/22
companycenter/22/events/22/22/22
....

bojanz’s picture

Can you retest with latest dev (7.x-3.x-dev)? I committed a fix for embedded Views that might help.

drbartje’s picture

I also have this issue. Using views_bulk_operations-7.x-3.0-beta3. I am not using Panels. The views is embedded in a node as a tab. I would expect the right value to be 'action="/drupal/node/NID/MYTAB/"' but instead I get 'action="/drupal/node/NID/MYTAB/NID"' and each time the form is submitted "/NID" is appended...

The view has a contextual filter and uses AJAX.

I've tried views_bulk_operations-7.x-3.x-dev but in this case I get 'action="/drupal/"' instead of 'action="/drupal/node/NID/MYTAB/"'.

If you need additional info please let me know.

Update

definitively related to the use of a contextual filter. I embed the view using

print views_embed_view('MYVIEW', 'block', $node->nid);

If I leave off the last parameter then things works as expected, i.e., 'action="/drupal/node/NID/MYTAB/"' and the node ID does not get appended. Of course, doing so I have too many entries in my view so not an option.

Strangely enough, even if I forcefully correct the form action to 'action="/drupal/node/NID/MYTAB/"' (e.g. by implementing hook_form_alter) then after submitting the form the node ID still gets appended. At least in doing so it gets appended only once and not endlessly...

I have tried using the "Skip default argument for view URL" option for the contextual filter but that doesn't solve the issue...

bojanz’s picture

You need to test with VBO 7.x-3.x-dev AND a recent Views version (3.3 is fine).
If you tried just the latest VBO without the recent Views, you wouldn't get the desired results.

Let me know if that changes anything, and I'll try to reproduce this anyway.

drbartje’s picture

I am using Views 7.x-3.3.

I've just tried again with VBO 7.x-3.0-rc1+14-dev.

When I examine the form in my hook_from_alter function (which runs after VBO and Views) then I see that $form['#action'] is set to '/drupal/'. As a result I am redirected to the site's landing page when I submit the form.

If I set $form['#action'] to '/drupal/node/NID/MYTAB/' in hook_from_alter then I do no longer get the erroneous additional node IDs in the URL. So at least I now have a way to make this work but it doesn't feel quite right... -> I must be doing something wrong... :-(

(btw thanks for an outstanding module and exemplary responsiveness!)

damiankloip’s picture

I am looking at the form too, I have tested on pages, tabs etc... and the #action seems to be correct from what I can see. Maybe this has been resolved by some earlier commits as bojanz suggested ^^ ? If not, do you have specific step to reproduce this?

nagiek’s picture

I haven't run into it either, yet. Running the latest.

If I encounter it I'll let you know, but haven't so far. I have no idea when it actually stopped appearing. :)

nagiek’s picture

Oops just kidding. Still happens. Running latest.

a.milkovsky’s picture

I've found a solution how to avoid this problem.
I deleted my Contextual Filter and created ordinary Filter Criteria using PHP code.
I wanted to get user id from URL so I typed

if(arg(1) != $row->uid){
 return TRUE;
}

And problem with form action gone.

To insert PHP into Filter Criteria i user module Views PHP

erichomanchuk’s picture

I have the same issue when using views_bulk_operations 7.x-3.0-rc1.

biz/customers/15
biz/customers/15/15/15
biz/customers/15/15/15/15/15/15

I'm adding the view block to the page with views_embed_view() and setting views to use AJAX.

When I upgrade to views_bulk_operations 7.x-3.x-dev version the form action is then set to / and it doesn't work only when I set the $form['#action'] = '/biz/customers/15' by using hook_form_alter like DrBartje suggested in comment #10 does it function properly.

nagiek’s picture

Time to fix some bugs.

What's wrong:

$form['#action'] is set explicitly. It calls $view->get_url(). This is where it's going wrong.

Normally, $view->get_url() will take the wildcards (denoted with %) and replaces them. However, the path it is receiving has already been replaced. (i.e. it's getting widgets/12, not widgets/%), so it has nothing to replace, and instead appends the args on the end. This results in the appended url problem.

Where it gets weird:

I believe (correct me if I'm wrong) that this is only happening for VBOs in panels. Which means views_content_plugin_display_panel_pane is responsible for generating the path.

The thing is, I have no idea how it's doing that. Every time i check for a return value, it says it's NULL. It tries to run its parent class, views_plugin_display, but that's not returning anything either. Maybe there's something override somewhere that just grabs $_GET['q']?

I don't know, need some help.

Options:

We could either:

  1. Change every instance of view->get_url() to view->get_path(), but I think that would break non-panel paths
  2. Fix views so it doesn't go appending stuff.
  3. Fix the content pane display to get the REAL url (with % operator).

I think #3 is the only option, assuming that only Panel views are being affected. If not, we have to fix views.

maxplus’s picture

Hi,

I have the same problem and the problem also dissapears when removing the contextual filter.
I tried the current dev version of views (2012-Jun-09) and VBO (2012-Jun-04) but then other strange things happen.

So the only current solution is to use a regular filter and modify it with php to create your own contextual filter like a.milkovsky posted in #14.

maxplus’s picture

Hi guys,

a short update.
While trying to use a regular php filter to achieve my goal, I just tried my original contextual filter once again with with one slight change:

I enabled " Skip default argument for view URL: Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds."

Now it is working fine, great!

nagiek’s picture

Drupa1ish’s picture

Thanks @nagiek for pointing me into the correct direction with #19.

Use case
My use case is to show a block with contextual filters on the product page. I have to do it with http://drupal.org/project/context, since Drupal Panels is not yet mature for drupal commerce http://drupal.org/sandbox/manarth/1349452

For Panels, the issues is solved with http://drupal.org/node/1284738#comment-5726882, already commited at the latest devs.

#18 is good, but not good enough. See http://drupal.org/node/1269794#comment-4951030 : Thanks for the information.

I set 'Skip default argument for view URL' in my arguments, but still the values are appended to the URL. Did I miss something? Well, as the option says, it only applies for default arguments
It works only if you don’t apply exposed filters with ajax before submit vbo operation.

Patch request regarding #1284738: Wrong form action URL for exposed filters of content pane view displays using contextual filters

There are still issues for block with contextual filters included with drupal context
My 2 cents
http://drupal.org/files/views-exposed-filter-url-1284738-21.patch takes a step to generalization calling $form['#action'] = url($view->display_handler->get_url());, instead of $form['#action'] = url($view->get_url());

Now, it’s up to other plugins to extend views_plugin_display. For drupal panels, we have
http://drupal.org/files/ctools-views_content-get_url-1284738-21.patch.

Conclusion: A patch for views_plugin_display_block.inc would be required, or another views_plugin_display

My ugly workaround
From the code http://drupal.org/node/1284738#comment-5017504, I added hard coded an or condition ($this->current_display== "my_block_name")

tanvirahmad’s picture

raphael apard’s picture

I enabled " Skip default argument for view URL and it's working for me.

bojanz’s picture

Status: Active » Fixed
  function get_url($args = NULL, $path = NULL) {
    if (!empty($this->override_url)) {
      return $this->override_url;
    }

If you set override_url instead of override_path, no appending will happen inside Views.
This is what VBO 7.x-3.0 does.
The latest -dev doesn't even call get_url() anymore, for more clarity. So this shouldn't be an issue anymore.

Status: Fixed » Closed (fixed)

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