Closed (duplicate)
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 May 2013 at 07:43 UTC
Updated:
16 Jan 2019 at 01:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ycshen commentedhi,
I create a patch for this problem.
if my patch is wrong,please let's me know.
if there are some other solutions,please share with me.
Comment #2
jerenus commentedBot.
Comment #3
jerenus commented#1: 2004960-delete-link-destantion-1.patch queued for re-testing.
Comment #4
ycshen commentedThank @DYdave 's help in DGO.
we talk about this problem on the following link.
https://groups.drupal.org/node/299073#comment-928483
the attachment is the example:
my patch will fix this problem, if a unique item in a page,when delete it ,the destantion will rediret to the previous page.
Comment #5
dawehnerThank you for the patch!
This is probably the case in many other situations (like comment delete etc.) so what about make this more generic and move this to a function? Additional: this really needs some documentation what is the problem and how we fix it. (I understand that, but many others won't)
Comment #6
alfababy commentedhi,
@ycshen, your patch is very useful.
I follow your patch add a option that user can choose whether enable this function. Maybe we can let user to choose it. That's friendly.
Cheers.
Comment #7
ycshen commentedHi guys,
Really sorry for the late follow-up on this issue but it has taken us more time than expected to investigate and get back to this ticket with an updated patch.
As @dawehner mentioned at #5:
Indeed, after further investigation we found out it would be the case in several other situations and certainly agree that making a generic function would be the way to go.
If there isn't a generic method, the code would have to be duplicated in several places which would be redundant.
Which handlers would have to be modified? (in which situations would this issue occur?)
So we would need to add a new method that would be common to these field handlers.
By getting back in the tree of views handlers, we found out this problem would occur for node, node revisions, user and comments, which would seem to inherit from the views_handler_field or views_handler_field_entity classes.
However, the User cancel link only extends the views_handler_field class, not to mention third party modules, so it seems that if we were to add a new method, we wouldn't have much choice other than adding it to the views_handler_field class.
Please find attached to this comment an updated patch against views-7.x-3.x at 22bf853, which adds a new method called delete_get_destination in views_handler_field.inc.
File attached as: views-delete-link-destination-2004960-7.patch.
The new method delete_get_destination allows overriding the standard drupal_get_destination() to redirect the user to the previous (page-1) if no results are found on the previous page, except for page 1.
Additionally, the patch will modify accordingly the node, revisions, comments and user delete related link field handlers to use the newly added method.
You will notice this patch doesn't have much documentation yet, because I wanted to first run the code through your validation to double check if this approach would seem more reasonable to you (than previous patch from #1).
If everything is fine with the code, I would surely be glad to work on adding more inline comments and improving Doc comment blocks since this is a significant new change.
Feel free to let me know if you would have any more comments, objections, feedbacks, issues or ideas with this updated patch, I would surely be glad to provide more information or explain in further details.
Thanks in advance to everyone for your comments, reviews, feedbacks and testing.
Cheers!
Comment #8
el1_1el commentedI tried the above patch (7) and it didn't really help my use case (perhaps I'm not using it correctly?). I'm trying to redirect users back to their main organic group page when they delete og content. So I ended up modifying views_handler_field_node_link_delete.inc
I'm wondering if maybe the destination parameter could(should?) be set in the Views UI using tokens?...or if perhaps my use case is too marginal for such a major overhaul.
Comment #9
ycshen commentedhi el ,
I think you should use delete_get_destination() in stated of drupal_get_destination() in your handler
Comment #10
el1_1el commentedThanks for the quick reply ycshen.
I forgot to mention something that may make my use case even more marginal (and a bit different from yours) so i'll explain in a bit more detail in case its relevant for you or anyone else.
When I tried the patch using delete_get_destination (without my og modification above), I was redirected to my default 404 page after deleting a node...which is what also happens when I use the original views code with drupal_get_destination. This is almost certainly because I am using a content pane view to generate custom buttons (including delete) for users, and embedding that button view in a node_view panel.
You can correct me if I'm wrong here but I *think* in both cases (drupal and delete) the destination parameter tries to return to the node page (rather than a view page as in your case which would be more the norm) that has since been deleted. I tried modifying delete_get_destination when I applied the patch with a "page-2" but got the same result so I went with my og customization + the original code to try and keep it simpler. I suggested the use of a customized destination parameter in case others have a similar use case because in my case I could then just get the og_group_ref in a hidden field of the view, and put it in as a token in a customized destination parameter....which is essentially what i'm doing in my customized handler.
Let me know if any of that doesnt make sense and i'll try to explain it a little better...but given that info do you think delete_get_destination would be useful in my case? I'm happy to test this further or perhaps help a bit with the code if I can. Thanks again
Comment #11
ycshen commentedhi el,
I think you need to find other issues and my patch can't help you fix your problem if drupal_get_destination also doesn't work.
And I will still try to help you to debug.
please make sure the following code worked well.
please provide some information:
Comment #12
el1_1el commentedHi ycshen,
So basically the url before delete is /node/123. I hit delete to delete /node/123. Then either drupal_get_destination or delete_get_destination tries to return me to /node/123...which I just deleted. So I added
to the original views_handler_field_node_link_delete.inc to return the user to the main og group page (node/12 for example) after they delete /node/123. This works just fine and I dont need to change it...I am just suggesting that adding a feature to the patch that allows one to set a custom destination in the views UI might be useful to others as well.
Thanks for the offer to assist and your work on the patch!
cheers,
el
Comment #13
ycshen commentedhi el,
Have you tried to define your own custom handler 'file[]=xxxx.inc' in info and inextend the views_handler_field_node_link_delete.inc handler with your own custom handler , which you could override the method:
delete_get_destination()
and add your code in there.....
Then in the View you should change the delete field handler you are currently using and use instead the custom handler you have created.
This would avoid having to modify the handler views_handler_field_node_link_delete.inc.
Please let us know if you are able to get any results with this method, it would be interesting for the work carried in this ticket.
Comment #14
gribnif commentedThere is another bug report, #1009646: Rendered links token replacement URL encoding is broken which contains a much simpler fix for this problem. The patch in #24 was written to fix a bug in token substitution, but it also fixes the destination and edit link with pager bug described here.
Comment #15
chris matthews commentedClosing in favor of issue #1009646: Rendered links token replacement URL encoding is broken