1

I'm trying to add a taxonomy term from the node in question as a url parameter, but am struggling to figure out how to do it without just going through the site and modifying all of the links that point to it.

So currently the path looks like this

node/{node}/edit?destination=/plan

I'd like to modify if to look like this for a specific content type.

node/{node}/edit?destination=/plan&year={field_plan_year}

Should this be done in the routes file? Can it be done in hook_form_alter? Does anyone have any suggestions as to where I might look for an example of this? Can this be done with something like Pathauto?

The reason behind my need for this is to filter a view (that is shown via the form template). The node edit screen shares a matching programmatically generated taxonomy term (in this case "year"). We need to be able to contextually filter the view based on the value of the term from within the node.

  • I wouldn't look to deeply in this query thingy. The root of your problem is: How to redirect after node form submit to a URL retrieved from a node value. Isn't it that? So maybe search for: node form redirect. And you'll probably find what you need. – leymannx Aug 22 '18 at 20:43
  • Ideally I'd like to append the query so that on the edit screen I can show a contextually filtered view (one that happens to share a taxonomy term with the node in question). Does that make sense? I don't think a node form redirect would handle it, unless that redirect was to the same form, but added the query. In this use case we generate several of the values in the node form programmatically one of which is a taxonomy term for year that is always set. – Shawn Matthews Aug 22 '18 at 20:46
  • This is some key information. Please update your question accordingly. – leymannx Aug 22 '18 at 20:49
  • Updated. I hope that makes sense. Thank you very much for your assistance. – Shawn Matthews Aug 22 '18 at 20:57
  • This requirement looks similar to a question I had myself a few month ago. You maybe could use an OutboundPathProcessor, see the answer from Stefanos Petrakis in this question – Hudri Aug 22 '18 at 21:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.