Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a content type whose nodes redirect to a view which lists them (instead of viewing the individual node pages). When users create nodes of this content type, they are taken back to the node edit page on submit. It would make more sense to instead take them to the specified redirect path - the view where they can see their newly-created node listed with the rest...
Comment | File | Size | Author |
---|---|---|---|
#1 | node_save_redirect-2326005-1.patch | 1.34 KB | BWPanda |
Comments
Comment #1
BWPanda CreditAttribution: BWPanda commentedThis patch does just that. On node save, if a node (or it's content type) has RH set to redirect, then it redirects to that path, otherwise it redirect back to the node edit page as normal.
Comment #2
olofbokedal CreditAttribution: olofbokedal commentedThis is perfect for most use cases. However, there are some cases where this could be annoying or confusing.
One example is if you have a Download content type. If these shouldn't be viewable nodes, it makes sense to redirect to the file path which causes a download. This would mean that the user would download the file every time (s)he creates/updates a node.
This could be implemented if its controllable by bundle. I don't want to clutter the workflow to much, but this should be doable.
Comment #3
seworthi CreditAttribution: seworthi commentedNeed to account for token's in the redirect. This worked for me.
Comment #4
olofbokedal CreditAttribution: olofbokedal at Odd Hill commentedThis needs a bit more work before it's ready for commit.
Have a look at how rabbit_hole_execute() handles the redirect. We need to respect both PHP and tokens (as mentioned in #3). Perhaps the best way would be to abstract the redirect logic to a new function which we then could call in the various form submissions.
Comment #5
dunx CreditAttribution: dunx commentedAgreed. If you create a node and normally end up on /node/% then the RH settings should kick in and do what they've been configured to do. I'm not sure why it arbitrarily takes you to the /node/%/edit page. Especially bad if the user does not have permission to edit this node.
In the meantime, I'll create a form override to do what I thought RH would do automatically for me. Happy coding :)